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)); \
88 static float int_as_float(uint32_t intval)
100 instr_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
101 const char *fmt, ...) __attribute__((format(__printf__, 4, 5)));
104 instr_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
105 const char *fmt, ...)
108 const char *parseinfo;
109 uint32_t offset = hw_offset + index * 4;
111 if (offset == head_offset)
113 else if (offset == tail_offset)
118 fprintf(out, "0x%08x: %s 0x%08x: %s", offset, parseinfo,
119 data[index], index == 0 ? "" : " ");
121 vfprintf(out, fmt, va);
126 decode_mi(uint32_t *data, uint32_t count, uint32_t hw_offset, int *failures)
128 unsigned int opcode, len = -1;
129 const char *post_sync_op = "";
134 unsigned int min_len;
135 unsigned int max_len;
138 { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" },
139 { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" },
140 { 0x30, 0x3f, 3, 3, "MI_BATCH_BUFFER" },
141 { 0x31, 0x3f, 2, 2, "MI_BATCH_BUFFER_START" },
142 { 0x14, 0x3f, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
143 { 0x04, 0, 1, 1, "MI_FLUSH" },
144 { 0x22, 0x1f, 3, 3, "MI_LOAD_REGISTER_IMM" },
145 { 0x13, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
146 { 0x12, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
147 { 0x00, 0, 1, 1, "MI_NOOP" },
148 { 0x11, 0x3f, 2, 2, "MI_OVERLAY_FLIP" },
149 { 0x07, 0, 1, 1, "MI_REPORT_HEAD" },
150 { 0x18, 0x3f, 2, 2, "MI_SET_CONTEXT" },
151 { 0x20, 0x3f, 3, 4, "MI_STORE_DATA_IMM" },
152 { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" },
153 { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" },
154 { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" },
155 { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT" },
156 { 0x16, 0x7f, 3, 3, "MI_SEMAPHORE_MBOX" },
157 { 0x26, 0x1f, 3, 4, "MI_FLUSH_DW" },
158 { 0x0b, 0, 1, 1, "MI_SUSPEND_FLUSH"},
161 /* check instruction length */
162 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
164 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
166 if (opcodes_mi[opcode].max_len > 1) {
168 (data[0] & opcodes_mi[opcode].len_mask) + 2;
169 if (len < opcodes_mi[opcode].min_len
170 || len > opcodes_mi[opcode].max_len) {
172 "Bad length (%d) in %s, [%d, %d]\n",
173 len, opcodes_mi[opcode].name,
174 opcodes_mi[opcode].min_len,
175 opcodes_mi[opcode].max_len);
182 switch ((data[0] & 0x1f800000) >> 23) {
184 instr_out(data, hw_offset, 0, "MI_BATCH_BUFFER_END\n");
187 instr_out(data, hw_offset, 0, "MI_SEMAPHORE_MBOX%s%s%s%s %u\n",
188 data[0] & (1 << 22) ? " global gtt," : "",
189 data[0] & (1 << 21) ? " update semaphore," : "",
190 data[0] & (1 << 20) ? " compare semaphore," : "",
191 data[0] & (1 << 18) ? " use compare reg" : "",
192 (data[0] & (0x3 << 16)) >> 16);
193 instr_out(data, hw_offset, 1, "value\n");
194 instr_out(data, hw_offset, 2, "address\n");
197 instr_out(data, hw_offset, 0, "MI_STORE_DATA_INDEX%s\n",
198 data[0] & (1 << 21) ? " use per-process HWS," : "");
199 instr_out(data, hw_offset, 1, "index\n");
200 instr_out(data, hw_offset, 2, "dword\n");
202 instr_out(data, hw_offset, 3, "upper dword\n");
205 if (data[0] & (1 << 22))
206 instr_out(data, hw_offset, 0,
207 "MI_NOOP write NOPID reg, val=0x%x\n",
208 data[0] & ((1 << 22) - 1));
210 instr_out(data, hw_offset, 0, "MI_NOOP\n");
213 switch (data[0] & (0x3 << 14)) {
215 post_sync_op = "no write";
218 post_sync_op = "write data";
221 post_sync_op = "reserved";
224 post_sync_op = "write TIMESTAMP";
227 instr_out(data, hw_offset, 0,
228 "MI_FLUSH_DW%s%s%s%s post_sync_op='%s' %s%s\n",
229 data[0] & (1 << 22) ?
230 " enable protected mem (BCS-only)," : "",
231 data[0] & (1 << 21) ? " store in hws," : "",
232 data[0] & (1 << 18) ? " invalidate tlb," : "",
233 data[0] & (1 << 17) ? " flush gfdt," : "",
235 data[0] & (1 << 8) ? " enable notify interrupt," : "",
237 " invalidate video state (BCS-only)," : "");
238 if (data[0] & (1 << 21))
239 instr_out(data, hw_offset, 1, "hws index\n");
241 instr_out(data, hw_offset, 1, "address\n");
242 instr_out(data, hw_offset, 2, "dword\n");
244 instr_out(data, hw_offset, 3, "upper dword\n");
248 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
250 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
253 instr_out(data, hw_offset, 0, "%s\n",
254 opcodes_mi[opcode].name);
255 for (i = 1; i < len; i++) {
257 BUFFER_FAIL(count, len,
258 opcodes_mi[opcode].name);
259 instr_out(data, hw_offset, i, "dword %d\n", i);
266 instr_out(data, hw_offset, 0, "MI UNKNOWN\n");
272 decode_2d_br00(uint32_t *data, uint32_t count, uint32_t hw_offset,
275 instr_out(data, hw_offset, 0,
276 "%s (rgb %sabled, alpha %sabled, src tile %d, dst tile %d)\n",
278 (data[count] & (1 << 20)) ? "en" : "dis",
279 (data[count] & (1 << 21)) ? "en" : "dis",
280 (data[count] >> 15) & 1, (data[count] >> 11) & 1);
283 static void decode_2d_br01(uint32_t *data, uint32_t count, uint32_t hw_offset)
286 switch ((data[count] >> 24) & 0x3) {
301 instr_out(data, hw_offset, count, "format %s, pitch %d, rop 0x%02x, "
302 "clipping %sabled, %s%s \n",
304 (short)(data[count] & 0xffff),
305 (data[count] >> 16) & 0xff,
306 data[count] & (1 << 30) ? "en" : "dis",
307 data[count] & (1 << 31) ? "solid pattern enabled, " : "",
308 data[count] & (1 << 31) ?
309 "mono pattern transparency enabled, " : "");
314 decode_2d(uint32_t *data, uint32_t count, uint32_t hw_offset, int *failures)
316 unsigned int opcode, len;
320 unsigned int min_len;
321 unsigned int max_len;
324 { 0x40, 5, 5, "COLOR_BLT" },
325 { 0x43, 6, 6, "SRC_COPY_BLT" },
326 { 0x01, 8, 8, "XY_SETUP_BLT" },
327 { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
328 { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
329 { 0x24, 2, 2, "XY_PIXEL_BLT" },
330 { 0x25, 3, 3, "XY_SCANLINES_BLT" },
331 { 0x26, 4, 4, "Y_TEXT_BLT" },
332 { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
333 { 0x50, 6, 6, "XY_COLOR_BLT" },
334 { 0x51, 6, 6, "XY_PAT_BLT" },
335 { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
336 { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
337 { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
338 { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
339 { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
340 { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
341 { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
342 { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
343 { 0x55, 9, 9, "XY_FULL_BLT" },
344 { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
345 { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
346 { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
347 { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
348 { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT"},
351 switch ((data[0] & 0x1fc00000) >> 22) {
353 instr_out(data, hw_offset, 0,
354 "XY_SCANLINES_BLT (pattern seed (%d, %d), dst tile %d)\n",
355 (data[0] >> 12) & 0x8,
356 (data[0] >> 8) & 0x8, (data[0] >> 11) & 1);
358 len = (data[0] & 0x000000ff) + 2;
360 fprintf(out, "Bad count in XY_SCANLINES_BLT\n");
362 BUFFER_FAIL(count, len, "XY_SCANLINES_BLT");
364 instr_out(data, hw_offset, 1, "dest (%d,%d)\n",
365 data[1] & 0xffff, data[1] >> 16);
366 instr_out(data, hw_offset, 2, "dest (%d,%d)\n",
367 data[2] & 0xffff, data[2] >> 16);
370 decode_2d_br00(data, 0, hw_offset, "XY_SETUP_BLT");
372 len = (data[0] & 0x000000ff) + 2;
374 fprintf(out, "Bad count in XY_SETUP_BLT\n");
376 BUFFER_FAIL(count, len, "XY_SETUP_BLT");
378 decode_2d_br01(data, 1, hw_offset);
379 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
380 data[2] & 0xffff, data[2] >> 16);
381 instr_out(data, hw_offset, 3, "cliprect (%d,%d)\n",
382 data[3] & 0xffff, data[3] >> 16);
383 instr_out(data, hw_offset, 4, "setup dst offset 0x%08x\n",
385 instr_out(data, hw_offset, 5, "setup background color\n");
386 instr_out(data, hw_offset, 6, "setup foreground color\n");
387 instr_out(data, hw_offset, 7, "color pattern offset\n");
390 decode_2d_br00(data, 0, hw_offset, "XY_SETUP_CLIP_BLT");
392 len = (data[0] & 0x000000ff) + 2;
394 fprintf(out, "Bad count in XY_SETUP_CLIP_BLT\n");
396 BUFFER_FAIL(count, len, "XY_SETUP_CLIP_BLT");
398 instr_out(data, hw_offset, 1, "cliprect (%d,%d)\n",
399 data[1] & 0xffff, data[2] >> 16);
400 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
401 data[2] & 0xffff, data[3] >> 16);
404 decode_2d_br00(data, 0, hw_offset,
405 "XY_SETUP_MONO_PATTERN_SL_BLT");
407 len = (data[0] & 0x000000ff) + 2;
410 "Bad count in XY_SETUP_MONO_PATTERN_SL_BLT\n");
412 BUFFER_FAIL(count, len, "XY_SETUP_MONO_PATTERN_SL_BLT");
414 decode_2d_br01(data, 1, hw_offset);
415 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
416 data[2] & 0xffff, data[2] >> 16);
417 instr_out(data, hw_offset, 3, "cliprect (%d,%d)\n",
418 data[3] & 0xffff, data[3] >> 16);
419 instr_out(data, hw_offset, 4, "setup dst offset 0x%08x\n",
421 instr_out(data, hw_offset, 5, "setup background color\n");
422 instr_out(data, hw_offset, 6, "setup foreground color\n");
423 instr_out(data, hw_offset, 7, "mono pattern dw0\n");
424 instr_out(data, hw_offset, 8, "mono pattern dw1\n");
427 decode_2d_br00(data, 0, hw_offset, "XY_COLOR_BLT");
429 len = (data[0] & 0x000000ff) + 2;
431 fprintf(out, "Bad count in XY_COLOR_BLT\n");
433 BUFFER_FAIL(count, len, "XY_COLOR_BLT");
435 decode_2d_br01(data, 1, hw_offset);
436 instr_out(data, hw_offset, 2, "(%d,%d)\n",
437 data[2] & 0xffff, data[2] >> 16);
438 instr_out(data, hw_offset, 3, "(%d,%d)\n",
439 data[3] & 0xffff, data[3] >> 16);
440 instr_out(data, hw_offset, 4, "offset 0x%08x\n", data[4]);
441 instr_out(data, hw_offset, 5, "color\n");
444 decode_2d_br00(data, 0, hw_offset, "XY_SRC_COPY_BLT");
446 len = (data[0] & 0x000000ff) + 2;
448 fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
450 BUFFER_FAIL(count, len, "XY_SRC_COPY_BLT");
452 decode_2d_br01(data, 1, hw_offset);
453 instr_out(data, hw_offset, 2, "dst (%d,%d)\n",
454 data[2] & 0xffff, data[2] >> 16);
455 instr_out(data, hw_offset, 3, "dst (%d,%d)\n",
456 data[3] & 0xffff, data[3] >> 16);
457 instr_out(data, hw_offset, 4, "dst offset 0x%08x\n", data[4]);
458 instr_out(data, hw_offset, 5, "src (%d,%d)\n",
459 data[5] & 0xffff, data[5] >> 16);
460 instr_out(data, hw_offset, 6, "src pitch %d\n",
461 (short)(data[6] & 0xffff));
462 instr_out(data, hw_offset, 7, "src offset 0x%08x\n", data[7]);
466 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
468 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
472 instr_out(data, hw_offset, 0, "%s\n",
473 opcodes_2d[opcode].name);
474 if (opcodes_2d[opcode].max_len > 1) {
475 len = (data[0] & 0x000000ff) + 2;
476 if (len < opcodes_2d[opcode].min_len ||
477 len > opcodes_2d[opcode].max_len) {
478 fprintf(out, "Bad count in %s\n",
479 opcodes_2d[opcode].name);
483 for (i = 1; i < len; i++) {
485 BUFFER_FAIL(count, len,
486 opcodes_2d[opcode].name);
487 instr_out(data, hw_offset, i, "dword %d\n", i);
494 instr_out(data, hw_offset, 0, "2D UNKNOWN\n");
500 decode_3d_1c(uint32_t *data, uint32_t count, uint32_t hw_offset, int *failures)
504 opcode = (data[0] & 0x00f80000) >> 19;
508 instr_out(data, hw_offset, 0,
509 "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n");
512 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_ENABLE %s\n",
513 data[0] & 1 ? "enabled" : "disabled");
516 instr_out(data, hw_offset, 0, "3DSTATE_MAP_COORD_SET_I830\n");
519 instr_out(data, hw_offset, 0, "3DSTATE_MAP_CUBE_I830\n");
522 instr_out(data, hw_offset, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
526 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n",
532 /** Sets the string dstname to describe the destination of the PS instruction */
534 i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask)
536 uint32_t a0 = data[i];
537 int dst_nr = (a0 >> 14) & 0xf;
542 if (((a0 >> 10) & 0xf) == 0xf) {
545 int dstmask_index = 0;
547 dstmask[dstmask_index++] = '.';
549 dstmask[dstmask_index++] = 'x';
551 dstmask[dstmask_index++] = 'y';
553 dstmask[dstmask_index++] = 'z';
555 dstmask[dstmask_index++] = 'w';
556 dstmask[dstmask_index++] = 0;
568 switch ((a0 >> 19) & 0x7) {
571 fprintf(out, "bad destination reg R%d\n", dst_nr);
572 sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
576 fprintf(out, "bad destination reg oC%d\n", dst_nr);
577 sprintf(dstname, "oC%s%s", dstmask, sat);
581 fprintf(out, "bad destination reg oD%d\n", dst_nr);
582 sprintf(dstname, "oD%s%s", dstmask, sat);
586 fprintf(out, "bad destination reg U%d\n", dst_nr);
587 sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
590 sprintf(dstname, "RESERVED");
596 i915_get_channel_swizzle(uint32_t select)
598 switch (select & 0x7) {
600 return (select & 8) ? "-x" : "x";
602 return (select & 8) ? "-y" : "y";
604 return (select & 8) ? "-z" : "z";
606 return (select & 8) ? "-w" : "w";
608 return (select & 8) ? "-0" : "0";
610 return (select & 8) ? "-1" : "1";
612 return (select & 8) ? "-bad" : "bad";
617 i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
621 sprintf(name, "R%d", src_nr);
623 fprintf(out, "bad src reg %s\n", name);
627 sprintf(name, "T%d", src_nr);
628 else if (src_nr == 8)
629 sprintf(name, "DIFFUSE");
630 else if (src_nr == 9)
631 sprintf(name, "SPECULAR");
632 else if (src_nr == 10)
633 sprintf(name, "FOG");
635 fprintf(out, "bad src reg T%d\n", src_nr);
636 sprintf(name, "RESERVED");
640 sprintf(name, "C%d", src_nr);
642 fprintf(out, "bad src reg %s\n", name);
647 fprintf(out, "bad src reg oC%d\n", src_nr);
652 fprintf(out, "bad src reg oD%d\n", src_nr);
655 sprintf(name, "U%d", src_nr);
657 fprintf(out, "bad src reg %s\n", name);
660 fprintf(out, "bad src reg type %d\n", src_type);
661 sprintf(name, "RESERVED");
666 static void i915_get_instruction_src0(uint32_t *data, int i, char *srcname)
668 uint32_t a0 = data[i];
669 uint32_t a1 = data[i + 1];
670 int src_nr = (a0 >> 2) & 0x1f;
671 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
672 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
673 const char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
674 const char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
677 i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
678 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
680 if (strcmp(swizzle, ".xyzw") != 0)
681 strcat(srcname, swizzle);
684 static void i915_get_instruction_src1(uint32_t *data, int i, char *srcname)
686 uint32_t a1 = data[i + 1];
687 uint32_t a2 = data[i + 2];
688 int src_nr = (a1 >> 8) & 0x1f;
689 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
690 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
691 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
692 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
695 i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname);
696 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
698 if (strcmp(swizzle, ".xyzw") != 0)
699 strcat(srcname, swizzle);
702 static void i915_get_instruction_src2(uint32_t *data, int i, char *srcname)
704 uint32_t a2 = data[i + 2];
705 int src_nr = (a2 >> 16) & 0x1f;
706 const char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
707 const char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
708 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
709 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
712 i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
713 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
715 if (strcmp(swizzle, ".xyzw") != 0)
716 strcat(srcname, swizzle);
720 i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
724 sprintf(name, "R%d", src_nr);
726 fprintf(out, "bad src reg %s\n", name);
730 sprintf(name, "T%d", src_nr);
731 else if (src_nr == 8)
732 sprintf(name, "DIFFUSE");
733 else if (src_nr == 9)
734 sprintf(name, "SPECULAR");
735 else if (src_nr == 10)
736 sprintf(name, "FOG");
738 fprintf(out, "bad src reg T%d\n", src_nr);
739 sprintf(name, "RESERVED");
745 fprintf(out, "bad src reg oC%d\n", src_nr);
750 fprintf(out, "bad src reg oD%d\n", src_nr);
753 fprintf(out, "bad src reg type %d\n", src_type);
754 sprintf(name, "RESERVED");
760 i915_decode_alu1(uint32_t *data, uint32_t hw_offset,
761 int i, char *instr_prefix, const char *op_name)
763 char dst[100], src0[100];
765 i915_get_instruction_dst(data, i, dst, 1);
766 i915_get_instruction_src0(data, i, src0);
768 instr_out(data, hw_offset, i++, "%s: %s %s, %s\n", instr_prefix,
770 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
771 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
775 i915_decode_alu2(uint32_t *data, uint32_t hw_offset,
776 int i, char *instr_prefix, const char *op_name)
778 char dst[100], src0[100], src1[100];
780 i915_get_instruction_dst(data, i, dst, 1);
781 i915_get_instruction_src0(data, i, src0);
782 i915_get_instruction_src1(data, i, src1);
784 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s\n", instr_prefix,
785 op_name, dst, src0, src1);
786 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
787 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
791 i915_decode_alu3(uint32_t *data, uint32_t hw_offset,
792 int i, char *instr_prefix, const char *op_name)
794 char dst[100], src0[100], src1[100], src2[100];
796 i915_get_instruction_dst(data, i, dst, 1);
797 i915_get_instruction_src0(data, i, src0);
798 i915_get_instruction_src1(data, i, src1);
799 i915_get_instruction_src2(data, i, src2);
801 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
802 op_name, dst, src0, src1, src2);
803 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
804 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
808 i915_decode_tex(uint32_t *data, uint32_t hw_offset, int i,
809 const char *instr_prefix, const char *tex_name)
811 uint32_t t0 = data[i];
812 uint32_t t1 = data[i + 1];
817 i915_get_instruction_dst(data, i, dst_name, 0);
818 i915_get_instruction_addr((t1 >> 24) & 0x7,
819 (t1 >> 17) & 0xf, addr_name);
820 sampler_nr = t0 & 0xf;
822 instr_out(data, hw_offset, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
823 tex_name, dst_name, sampler_nr, addr_name);
824 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
825 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
829 i915_decode_dcl(uint32_t *data, uint32_t hw_offset, int i, char *instr_prefix)
831 uint32_t d0 = data[i];
832 const char *sampletype;
833 int dcl_nr = (d0 >> 14) & 0xf;
834 const char *dcl_x = d0 & (1 << 10) ? "x" : "";
835 const char *dcl_y = d0 & (1 << 11) ? "y" : "";
836 const char *dcl_z = d0 & (1 << 12) ? "z" : "";
837 const char *dcl_w = d0 & (1 << 13) ? "w" : "";
840 switch ((d0 >> 19) & 0x3) {
842 sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
843 if (strcmp(dcl_mask, ".") == 0)
844 fprintf(out, "bad (empty) dcl mask\n");
847 fprintf(out, "bad T%d dcl register number\n", dcl_nr);
849 if (strcmp(dcl_mask, ".x") != 0 &&
850 strcmp(dcl_mask, ".xy") != 0 &&
851 strcmp(dcl_mask, ".xz") != 0 &&
852 strcmp(dcl_mask, ".w") != 0 &&
853 strcmp(dcl_mask, ".xyzw") != 0) {
854 fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr,
857 instr_out(data, hw_offset, i++, "%s: DCL T%d%s\n",
858 instr_prefix, dcl_nr, dcl_mask);
860 if (strcmp(dcl_mask, ".xz") == 0)
861 fprintf(out, "errataed bad dcl mask %s\n",
863 else if (strcmp(dcl_mask, ".xw") == 0)
864 fprintf(out, "errataed bad dcl mask %s\n",
866 else if (strcmp(dcl_mask, ".xzw") == 0)
867 fprintf(out, "errataed bad dcl mask %s\n",
871 instr_out(data, hw_offset, i++,
872 "%s: DCL DIFFUSE%s\n", instr_prefix,
874 } else if (dcl_nr == 9) {
875 instr_out(data, hw_offset, i++,
876 "%s: DCL SPECULAR%s\n", instr_prefix,
878 } else if (dcl_nr == 10) {
879 instr_out(data, hw_offset, i++,
880 "%s: DCL FOG%s\n", instr_prefix,
884 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
885 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
888 switch ((d0 >> 22) & 0x3) {
899 sampletype = "RESERVED";
903 fprintf(out, "bad S%d dcl register number\n", dcl_nr);
904 instr_out(data, hw_offset, i++, "%s: DCL S%d %s\n",
905 instr_prefix, dcl_nr, sampletype);
906 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
907 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
910 instr_out(data, hw_offset, i++, "%s: DCL RESERVED%d\n",
911 instr_prefix, dcl_nr);
912 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
913 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
918 i915_decode_instruction(uint32_t *data, uint32_t hw_offset,
919 int i, char *instr_prefix)
921 switch ((data[i] >> 24) & 0x1f) {
923 instr_out(data, hw_offset, i++, "%s: NOP\n", instr_prefix);
924 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
925 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
928 i915_decode_alu2(data, hw_offset, i, instr_prefix, "ADD");
931 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOV");
934 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MUL");
937 i915_decode_alu3(data, hw_offset, i, instr_prefix, "MAD");
940 i915_decode_alu3(data, hw_offset, i, instr_prefix, "DP2ADD");
943 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP3");
946 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP4");
949 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FRC");
952 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RCP");
955 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RSQ");
958 i915_decode_alu1(data, hw_offset, i, instr_prefix, "EXP");
961 i915_decode_alu1(data, hw_offset, i, instr_prefix, "LOG");
964 i915_decode_alu2(data, hw_offset, i, instr_prefix, "CMP");
967 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MIN");
970 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MAX");
973 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FLR");
976 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOD");
979 i915_decode_alu1(data, hw_offset, i, instr_prefix, "TRC");
982 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SGE");
985 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SLT");
988 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLD");
991 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDP");
994 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDB");
997 i915_decode_dcl(data, hw_offset, i, instr_prefix);
1000 instr_out(data, hw_offset, i++, "%s: unknown\n", instr_prefix);
1001 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
1002 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
1008 decode_compare_func(uint32_t op)
1032 decode_stencil_op(uint32_t op)
1057 decode_logic_op(uint32_t op)
1098 decode_blend_fact(uint32_t op)
1108 return "inv_src_colr";
1112 return "inv_src_alpha";
1116 return "inv_dst_alpha";
1120 return "inv_dst_colr";
1122 return "src_alpha_sat";
1126 return "inv_cnst_colr";
1128 return "cnst_alpha";
1130 return "inv_const_alpha";
1136 decode_tex_coord_mode(uint32_t mode)
1138 switch (mode & 0x7) {
1144 return "clamp_edge";
1148 return "clamp_border";
1150 return "mirror_once";
1156 decode_sample_filter(uint32_t mode)
1158 switch (mode & 0x7) {
1164 return "anisotropic";
1178 decode_3d_1d(uint32_t *data, uint32_t count,
1179 uint32_t hw_offset, uint32_t devid, int *failures)
1181 unsigned int len, i, c, idx, word, map, sampler, instr;
1182 const char *format, *zformat, *type;
1188 unsigned int min_len;
1189 unsigned int max_len;
1191 } opcodes_3d_1d[] = {
1192 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
1193 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
1194 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
1195 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
1196 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
1197 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
1198 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
1199 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
1200 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
1201 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
1202 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
1203 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
1204 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
1205 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
1206 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
1207 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830"},
1210 opcode = (data[0] & 0x00ff0000) >> 16;
1214 /* This instruction is unusual. A 0 length means just
1215 * 1 DWORD instead of 2. The 0 length is specified in
1216 * one place to be unsupported, but stated to be
1217 * required in another, and 0 length LOAD_INDIRECTs
1218 * appear to cause no harm at least.
1220 instr_out(data, hw_offset, 0, "3DSTATE_LOAD_INDIRECT\n");
1221 len = (data[0] & 0x000000ff) + 1;
1223 if (data[0] & (0x01 << 8)) {
1225 BUFFER_FAIL(count, len,
1226 "3DSTATE_LOAD_INDIRECT");
1227 instr_out(data, hw_offset, i++, "SIS.0\n");
1228 instr_out(data, hw_offset, i++, "SIS.1\n");
1230 if (data[0] & (0x02 << 8)) {
1232 BUFFER_FAIL(count, len,
1233 "3DSTATE_LOAD_INDIRECT");
1234 instr_out(data, hw_offset, i++, "DIS.0\n");
1236 if (data[0] & (0x04 << 8)) {
1238 BUFFER_FAIL(count, len,
1239 "3DSTATE_LOAD_INDIRECT");
1240 instr_out(data, hw_offset, i++, "SSB.0\n");
1241 instr_out(data, hw_offset, i++, "SSB.1\n");
1243 if (data[0] & (0x08 << 8)) {
1245 BUFFER_FAIL(count, len,
1246 "3DSTATE_LOAD_INDIRECT");
1247 instr_out(data, hw_offset, i++, "MSB.0\n");
1248 instr_out(data, hw_offset, i++, "MSB.1\n");
1250 if (data[0] & (0x10 << 8)) {
1252 BUFFER_FAIL(count, len,
1253 "3DSTATE_LOAD_INDIRECT");
1254 instr_out(data, hw_offset, i++, "PSP.0\n");
1255 instr_out(data, hw_offset, i++, "PSP.1\n");
1257 if (data[0] & (0x20 << 8)) {
1259 BUFFER_FAIL(count, len,
1260 "3DSTATE_LOAD_INDIRECT");
1261 instr_out(data, hw_offset, i++, "PSC.0\n");
1262 instr_out(data, hw_offset, i++, "PSC.1\n");
1265 fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
1271 instr_out(data, hw_offset, 0,
1272 "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1273 len = (data[0] & 0x0000000f) + 2;
1275 for (word = 0; word <= 8; word++) {
1276 if (data[0] & (1 << (4 + word))) {
1278 BUFFER_FAIL(count, len,
1279 "3DSTATE_LOAD_STATE_IMMEDIATE_1");
1281 /* save vertex state for decode */
1282 if (!IS_GEN2(devid)) {
1296 instr_out(data, hw_offset, i,
1297 "S0: vbo offset: 0x%08x%s\n",
1300 ", auto cache invalidate disabled"
1304 instr_out(data, hw_offset, i,
1305 "S1: vertex width: %i, vertex pitch: %i\n",
1312 instr_out(data, hw_offset, i,
1313 "S2: texcoord formats: ");
1315 tex_num < 8; tex_num++) {
1360 instr_out(data, hw_offset, i,
1361 "S3: not documented\n");
1365 const char *cullmode = "";
1366 const char *vfmt_xyzw = "";
1367 switch ((data[i] >> 13)
1404 case 1 << 6 | 1 << 2:
1408 case 2 << 6 | 1 << 2:
1412 case 3 << 6 | 1 << 2:
1416 case 4 << 6 | 1 << 2:
1423 "S4: point_width=%i, line_width=%.1f,"
1424 "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s "
1487 "force default diffuse, "
1493 "force default specular, "
1499 "local depth ofs enable, "
1505 "point sprite enable, "
1520 "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, "
1521 "stencil_fail=%s, stencil_pass_z_fail=%s, "
1522 "stencil_pass_z_pass=%s, %s%s%s%s\n",
1552 " force default point size,"
1558 " last pixel enable,"
1564 " global depth ofs enable,"
1590 "stencil write enable, "
1596 "stencil test enable, "
1602 "color dither enable, "
1613 instr_out(data, hw_offset, i,
1614 "S6: %salpha_test=%s, alpha_ref=0x%x, "
1615 "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, "
1616 "%s%stristrip_provoking_vertex=%i\n",
1617 data[i] & (1 << 31) ?
1618 "alpha test enable, "
1626 data[i] & (1 << 15) ?
1627 "cbuf blend enable, "
1629 decode_blend_fact(data
1633 decode_blend_fact(data
1637 data[i] & (1 << 3) ?
1638 "depth write enable, "
1640 data[i] & (1 << 2) ?
1641 "cbuf write enable, "
1646 instr_out(data, hw_offset, i,
1647 "S7: depth offset constant: 0x%08x\n",
1652 instr_out(data, hw_offset, i,
1653 "S%d: 0x%08x\n", i, data[i]);
1660 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1665 instr_out(data, hw_offset, 0,
1666 "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1667 len = (data[0] & 0x0000000f) + 2;
1669 for (word = 6; word <= 14; word++) {
1670 if (data[0] & (1 << word)) {
1672 BUFFER_FAIL(count, len,
1673 "3DSTATE_LOAD_STATE_IMMEDIATE_2");
1676 instr_out(data, hw_offset, i++,
1678 else if (word >= 7 && word <= 10) {
1679 instr_out(data, hw_offset, i++,
1680 "TB%dC\n", word - 7);
1681 instr_out(data, hw_offset, i++,
1682 "TB%dA\n", word - 7);
1683 } else if (word >= 11 && word <= 14) {
1684 instr_out(data, hw_offset, i,
1685 "TM%dS0: offset=0x%08x, %s\n",
1687 data[i] & 0xfffffffe,
1688 data[i] & 1 ? "use fence" :
1691 instr_out(data, hw_offset, i,
1692 "TM%dS1: height=%i, width=%i, %s\n",
1693 word - 11, data[i] >> 21,
1694 (data[i] >> 10) & 0x3ff,
1695 data[i] & 2 ? (data[i] & 1 ?
1700 instr_out(data, hw_offset, i,
1701 "TM%dS2: pitch=%i, \n",
1703 ((data[i] >> 21) + 1) * 4);
1705 instr_out(data, hw_offset, i++,
1706 "TM%dS3\n", word - 11);
1707 instr_out(data, hw_offset, i++,
1708 "TM%dS4: dflt color\n",
1715 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1720 instr_out(data, hw_offset, 0, "3DSTATE_MAP_STATE\n");
1721 len = (data[0] & 0x0000003f) + 2;
1722 instr_out(data, hw_offset, 1, "mask\n");
1725 for (map = 0; map <= 15; map++) {
1726 if (data[1] & (1 << map)) {
1727 int width, height, pitch, dword;
1731 BUFFER_FAIL(count, len,
1732 "3DSTATE_MAP_STATE");
1735 instr_out(data, hw_offset, i++,
1736 "map %d MS2 %s%s%s\n", map,
1738 "untrusted surface, " : "",
1740 "vertical line stride enable, " : "",
1742 "vertical ofs enable, " : "");
1745 width = ((dword >> 10) & ((1 << 11) - 1)) + 1;
1746 height = ((dword >> 21) & ((1 << 11) - 1)) + 1;
1749 if (dword & (1 << 2))
1751 else if (dword & (1 << 1))
1752 tiling = dword & (1 << 0) ? "Y" : "X";
1755 switch ((dword >> 7) & 0x7) {
1758 switch ((dword >> 3) & 0xf) {
1775 switch ((dword >> 3) & 0xf) {
1780 format = " argb1555";
1783 format = " argb4444";
1789 format = " bump655";
1804 switch ((dword >> 3) & 0xf) {
1806 format = " argb8888";
1809 format = " abgr8888";
1812 format = " xrgb8888";
1815 format = " xbgr8888";
1818 format = " qwvu8888";
1821 format = " axvu8888";
1824 format = " lxvu8888";
1827 format = " xlvu8888";
1830 format = " argb2101010";
1833 format = " abgr2101010";
1836 format = " awvu2101010";
1857 switch ((dword >> 3) & 0xf) {
1859 format = " yuv_swapy";
1865 format = " yuv_swapuv";
1868 format = " yuv_swapuvy";
1873 type = "compressed";
1874 switch ((dword >> 3) & 0x7) {
1888 format = " dxt1_rb";
1893 type = "4b indexed";
1894 switch ((dword >> 3) & 0xf) {
1896 format = " argb8888";
1902 instr_out(data, hw_offset, i++,
1903 "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n",
1904 map, width, height, type, format,
1906 dword & (1 << 9) ? " palette select" :
1911 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1);
1912 instr_out(data, hw_offset, i++,
1913 "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n",
1914 map, pitch, (dword >> 9) & 0x3f,
1915 dword & 0xff, (dword >> 15) & 0x3f,
1916 dword & (1 << 8) ? "miplayout legacy"
1917 : "miplayout right");
1921 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
1927 instr_out(data, hw_offset, 0,
1928 "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1929 len = (data[0] & 0x000000ff) + 2;
1932 for (c = 0; c <= 31; c++) {
1933 if (data[1] & (1 << c)) {
1935 BUFFER_FAIL(count, len,
1936 "3DSTATE_PIXEL_SHADER_CONSTANTS");
1937 instr_out(data, hw_offset, i, "C%d.X = %f\n", c,
1938 int_as_float(data[i]));
1940 instr_out(data, hw_offset, i, "C%d.Y = %f\n",
1941 c, int_as_float(data[i]));
1943 instr_out(data, hw_offset, i, "C%d.Z = %f\n",
1944 c, int_as_float(data[i]));
1946 instr_out(data, hw_offset, i, "C%d.W = %f\n",
1947 c, int_as_float(data[i]));
1953 "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1958 instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
1959 len = (data[0] & 0x000000ff) + 2;
1960 if ((len - 1) % 3 != 0 || len > 370) {
1962 "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");
2050 len = (data[0] & 0x0000000f) + 2;
2054 "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
2056 BUFFER_FAIL(count, len,
2057 "3DSTATE_DEST_BUFFER_VARIABLES");
2059 instr_out(data, hw_offset, 0,
2060 "3DSTATE_DEST_BUFFER_VARIABLES\n");
2062 switch ((data[1] >> 8) & 0xf) {
2067 format = "x1r5g5b5";
2073 format = "a8r8g8b8";
2076 format = "ycrcb_swapy";
2079 format = "ycrcb_normal";
2082 format = "ycrcb_swapuv";
2085 format = "ycrcb_swapuvy";
2088 format = "a4r4g4b4";
2091 format = "a1r5g5b5";
2094 format = "a2r10g10b10";
2100 switch ((data[1] >> 2) & 0x3) {
2114 instr_out(data, hw_offset, 1,
2115 "%s format, %s depth format, early Z %sabled\n",
2117 (data[1] & (1 << 31)) ? "en" : "dis");
2122 const char *name, *tiling;
2124 len = (data[0] & 0x0000000f) + 2;
2127 "Bad count in 3DSTATE_BUFFER_INFO\n");
2129 BUFFER_FAIL(count, len, "3DSTATE_BUFFER_INFO");
2131 switch ((data[1] >> 24) & 0x7) {
2144 if (data[1] & (1 << 23))
2146 else if (data[1] & (1 << 22))
2147 tiling = data[1] & (1 << 21) ? "Y" : "X";
2149 instr_out(data, hw_offset, 0, "3DSTATE_BUFFER_INFO\n");
2150 instr_out(data, hw_offset, 1,
2151 "%s, tiling = %s, pitch=%d\n", name, tiling,
2154 instr_out(data, hw_offset, 2, "address\n");
2158 len = (data[0] & 0x0000000f) + 2;
2162 "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n");
2164 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_RECTANGLE");
2166 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_RECTANGLE\n");
2167 instr_out(data, hw_offset, 1, "(%d,%d)\n",
2168 data[1] & 0xffff, data[1] >> 16);
2169 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2170 data[2] & 0xffff, data[2] >> 16);
2174 len = (data[0] & 0x0000000f) + 2;
2178 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2180 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
2182 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
2183 instr_out(data, hw_offset, 1, "%s\n",
2184 data[1] & (1 << 30) ? "depth ofs disabled " : "");
2185 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2186 data[2] & 0xffff, data[2] >> 16);
2187 instr_out(data, hw_offset, 3, "(%d,%d)\n",
2188 data[3] & 0xffff, data[3] >> 16);
2189 instr_out(data, hw_offset, 4, "(%d,%d)\n",
2190 data[4] & 0xffff, data[4] >> 16);
2194 len = (data[0] & 0x0000000f) + 2;
2197 fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n");
2199 BUFFER_FAIL(count, len, "3DSTATE_CLEAR_PARAMETERS");
2201 instr_out(data, hw_offset, 0, "3DSTATE_CLEAR_PARAMETERS\n");
2202 instr_out(data, hw_offset, 1, "prim_type=%s, clear=%s%s%s\n",
2203 data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT",
2204 data[1] & (1 << 2) ? "color," : "",
2205 data[1] & (1 << 1) ? "depth," : "",
2206 data[1] & (1 << 0) ? "stencil," : "");
2207 instr_out(data, hw_offset, 2, "clear color\n");
2208 instr_out(data, hw_offset, 3, "clear depth/stencil\n");
2209 instr_out(data, hw_offset, 4, "color value (rgba8888)\n");
2210 instr_out(data, hw_offset, 5, "depth value %f\n",
2211 int_as_float(data[5]));
2212 instr_out(data, hw_offset, 6, "clear stencil\n");
2216 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) {
2217 opcode_3d_1d = &opcodes_3d_1d[idx];
2218 if (opcode_3d_1d->i830_only && !IS_GEN2(devid))
2221 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
2224 instr_out(data, hw_offset, 0, "%s\n",
2225 opcode_3d_1d->name);
2226 if (opcode_3d_1d->max_len > 1) {
2227 len = (data[0] & 0x0000ffff) + 2;
2228 if (len < opcode_3d_1d->min_len ||
2229 len > opcode_3d_1d->max_len) {
2230 fprintf(out, "Bad count in %s\n",
2231 opcode_3d_1d->name);
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",
2254 decode_3d_primitive(uint32_t *data, uint32_t count, uint32_t hw_offset,
2257 char immediate = (data[0] & (1 << 23)) == 0;
2258 unsigned int len, i, j, ret;
2259 const char *primtype;
2260 int original_s2 = saved_s2;
2261 int original_s4 = saved_s4;
2263 switch ((data[0] >> 18) & 0xf) {
2265 primtype = "TRILIST";
2268 primtype = "TRISTRIP";
2271 primtype = "TRISTRIP_REVERSE";
2274 primtype = "TRIFAN";
2277 primtype = "POLYGON";
2280 primtype = "LINELIST";
2283 primtype = "LINESTRIP";
2286 primtype = "RECTLIST";
2289 primtype = "POINTLIST";
2295 primtype = "CLEAR_RECT";
2300 primtype = "unknown";
2304 /* XXX: 3DPRIM_DIB not supported */
2306 len = (data[0] & 0x0003ffff) + 2;
2307 instr_out(data, hw_offset, 0, "3DPRIMITIVE inline %s\n",
2310 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
2311 if (!saved_s2_set || !saved_s4_set) {
2312 fprintf(out, "unknown vertex format\n");
2313 for (i = 1; i < len; i++) {
2314 instr_out(data, hw_offset, i,
2315 " vertex data (%f float)\n",
2316 int_as_float(data[i]));
2319 unsigned int vertex = 0;
2320 for (i = 1; i < len;) {
2323 #define VERTEX_OUT(fmt, ...) do { \
2325 instr_out(data, hw_offset, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
2327 fprintf(out, " missing data in V%d\n", vertex); \
2331 VERTEX_OUT("X = %f", int_as_float(data[i]));
2332 VERTEX_OUT("Y = %f", int_as_float(data[i]));
2333 switch (saved_s4 >> 6 & 0x7) {
2335 VERTEX_OUT("Z = %f",
2336 int_as_float(data[i]));
2339 VERTEX_OUT("Z = %f",
2340 int_as_float(data[i]));
2341 VERTEX_OUT("W = %f",
2342 int_as_float(data[i]));
2347 VERTEX_OUT("W = %f",
2348 int_as_float(data[i]));
2351 fprintf(out, "bad S4 position mask\n");
2354 if (saved_s4 & (1 << 10)) {
2356 ("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
2357 "B=0x%02x)", data[i] >> 24,
2358 (data[i] >> 16) & 0xff,
2359 (data[i] >> 8) & 0xff,
2362 if (saved_s4 & (1 << 11)) {
2364 ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
2365 "B=0x%02x)", data[i] >> 24,
2366 (data[i] >> 16) & 0xff,
2367 (data[i] >> 8) & 0xff,
2370 if (saved_s4 & (1 << 12))
2371 VERTEX_OUT("width = 0x%08x)", data[i]);
2373 for (tc = 0; tc <= 7; tc++) {
2374 switch ((saved_s2 >> (tc * 4)) & 0xf) {
2376 VERTEX_OUT("T%d.X = %f", tc,
2379 VERTEX_OUT("T%d.Y = %f", tc,
2384 VERTEX_OUT("T%d.X = %f", tc,
2387 VERTEX_OUT("T%d.Y = %f", tc,
2390 VERTEX_OUT("T%d.Z = %f", tc,
2395 VERTEX_OUT("T%d.X = %f", tc,
2398 VERTEX_OUT("T%d.Y = %f", tc,
2401 VERTEX_OUT("T%d.Z = %f", tc,
2404 VERTEX_OUT("T%d.W = %f", tc,
2409 VERTEX_OUT("T%d.X = %f", tc,
2415 ("T%d.XY = 0x%08x half-float",
2420 ("T%d.XY = 0x%08x half-float",
2423 ("T%d.ZW = 0x%08x half-float",
2430 "bad S2.T%d format\n",
2440 /* indirect vertices */
2441 len = data[0] & 0x0000ffff; /* index count */
2442 if (data[0] & (1 << 17)) {
2443 /* random vertex access */
2444 if (count < (len + 1) / 2 + 1) {
2445 BUFFER_FAIL(count, (len + 1) / 2 + 1,
2446 "3DPRIMITIVE random indirect");
2448 instr_out(data, hw_offset, 0,
2449 "3DPRIMITIVE random indirect %s (%d)\n",
2452 /* vertex indices continue until 0xffff is
2455 for (i = 1; i < count; i++) {
2456 if ((data[i] & 0xffff) == 0xffff) {
2457 instr_out(data, hw_offset, i,
2458 " indices: (terminator)\n");
2461 } else if ((data[i] >> 16) == 0xffff) {
2462 instr_out(data, hw_offset, i,
2463 " indices: 0x%04x, (terminator)\n",
2468 instr_out(data, hw_offset, i,
2469 " indices: 0x%04x, 0x%04x\n",
2475 "3DPRIMITIVE: no terminator found in index buffer\n");
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(uint32_t *data, uint32_t count, uint32_t hw_offset, uint32_t devid,
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(data, count, hw_offset, failures);
2546 return decode_3d_1d(data, count, hw_offset, devid, failures);
2548 return decode_3d_1c(data, count, hw_offset, failures);
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);
2581 static const char *get_965_surfacetype(unsigned int surfacetype)
2583 switch (surfacetype) {
2601 static const char *get_965_depthformat(unsigned int depthformat)
2603 switch (depthformat) {
2605 return "s8_z24float";
2617 static const char *get_965_element_component(uint32_t data, int component)
2619 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
2621 switch (component_control) {
2625 switch (component) {
2650 static const char *get_965_prim_type(uint32_t data)
2652 uint32_t primtype = (data >> 10) & 0x1f;
2656 return "point list";
2660 return "line strip";
2670 return "quad strip";
2672 return "line list adj";
2674 return "line strip adj";
2676 return "tri list adj";
2678 return "tri strip adj";
2680 return "tri strip reverse";
2688 return "point list bf";
2690 return "line strip cont";
2692 return "line strip bf";
2694 return "line strip cont bf";
2696 return "tri fan no stipple";
2703 i965_decode_urb_fence(uint32_t *data, uint32_t hw_offset, int len, uint32_t count,
2706 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
2709 fprintf(out, "Bad count in URB_FENCE\n");
2711 BUFFER_FAIL(count, len, "URB_FENCE");
2713 vs_fence = data[1] & 0x3ff;
2714 gs_fence = (data[1] >> 10) & 0x3ff;
2715 clip_fence = (data[1] >> 20) & 0x3ff;
2716 sf_fence = data[2] & 0x3ff;
2717 vfe_fence = (data[2] >> 10) & 0x3ff;
2718 cs_fence = (data[2] >> 20) & 0x7ff;
2720 instr_out(data, hw_offset, 0, "URB_FENCE: %s%s%s%s%s%s\n",
2721 (data[0] >> 13) & 1 ? "cs " : "",
2722 (data[0] >> 12) & 1 ? "vfe " : "",
2723 (data[0] >> 11) & 1 ? "sf " : "",
2724 (data[0] >> 10) & 1 ? "clip " : "",
2725 (data[0] >> 9) & 1 ? "gs " : "",
2726 (data[0] >> 8) & 1 ? "vs " : "");
2727 instr_out(data, hw_offset, 1,
2728 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
2729 vs_fence, clip_fence, gs_fence);
2730 instr_out(data, hw_offset, 2,
2731 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
2732 sf_fence, vfe_fence, cs_fence);
2733 if (gs_fence < vs_fence)
2734 fprintf(out, "gs fence < vs fence!\n");
2735 if (clip_fence < gs_fence)
2736 fprintf(out, "clip fence < gs fence!\n");
2737 if (sf_fence < clip_fence)
2738 fprintf(out, "sf fence < clip fence!\n");
2739 if (cs_fence < sf_fence)
2740 fprintf(out, "cs fence < sf fence!\n");
2746 state_base_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2749 if (data[index] & 1) {
2750 instr_out(data, hw_offset, index,
2751 "%s state base address 0x%08x\n", name,
2754 instr_out(data, hw_offset, index, "%s state base not updated\n",
2760 state_max_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2763 if (data[index] & 1) {
2764 if (data[index] == 1) {
2765 instr_out(data, hw_offset, index,
2766 "%s state upper bound disabled\n", name);
2768 instr_out(data, hw_offset, index,
2769 "%s state upper bound 0x%08x\n", name,
2773 instr_out(data, hw_offset, index,
2774 "%s state upper bound not updated\n", name);
2779 decode_3d_965(uint32_t *data, uint32_t count, uint32_t hw_offset, uint32_t devid,
2783 unsigned int idx, len;
2784 unsigned int i, j, sba_len;
2785 const char *desc1 = NULL;
2789 int unsigned min_len;
2790 int unsigned max_len;
2793 { 0x6000, 3, 3, "URB_FENCE" },
2794 { 0x6001, 2, 2, "CS_URB_STATE" },
2795 { 0x6002, 2, 2, "CONSTANT_BUFFER" },
2796 { 0x6101, 6, 6, "STATE_BASE_ADDRESS" },
2797 { 0x6102, 2, 2, "STATE_SIP" },
2798 { 0x6104, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2799 { 0x680b, 1, 1, "3DSTATE_VF_STATISTICS" },
2800 { 0x6904, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2801 { 0x7800, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
2802 { 0x7801, 6, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
2803 { 0x7808, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
2804 { 0x7809, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
2805 { 0x780a, 3, 3, "3DSTATE_INDEX_BUFFER" },
2806 { 0x780b, 1, 1, "3DSTATE_VF_STATISTICS" },
2807 { 0x7900, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
2808 { 0x7901, 5, 5, "3DSTATE_CONSTANT_COLOR" },
2809 { 0x7905, 5, 7, "3DSTATE_DEPTH_BUFFER" },
2810 { 0x7906, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
2811 { 0x7907, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
2812 { 0x7908, 3, 3, "3DSTATE_LINE_STIPPLE" },
2813 { 0x7909, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
2814 { 0x7909, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2815 { 0x790a, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
2816 { 0x790b, 4, 4, "3DSTATE_GS_SVB_INDEX" },
2817 { 0x790d, 3, 3, "3DSTATE_MULTISAMPLE" },
2818 { 0x7910, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2819 { 0x7b00, 6, 6, "3DPRIMITIVE" },
2820 { 0x7802, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
2821 { 0x7805, 3, 3, "3DSTATE_URB" },
2822 { 0x780d, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
2823 { 0x780e, 4, 4, "3DSTATE_CC_STATE_POINTERS" },
2824 { 0x780f, 2, 2, "3DSTATE_SCISSOR_STATE_POINTERS" },
2825 { 0x7810, 6, 6, "3DSTATE_VS_STATE" },
2826 { 0x7811, 7, 7, "3DSTATE_GS_STATE" },
2827 { 0x7812, 4, 4, "3DSTATE_CLIP_STATE" },
2828 { 0x7813, 20, 20, "3DSTATE_SF_STATE" },
2829 { 0x7814, 9, 9, "3DSTATE_WM_STATE" },
2830 { 0x7815, 5, 5, "3DSTATE_CONSTANT_VS_STATE" },
2831 { 0x7816, 5, 5, "3DSTATE_CONSTANT_GS_STATE" },
2832 { 0x7817, 5, 5, "3DSTATE_CONSTANT_PS_STATE" },
2833 { 0x7818, 2, 2, "3DSTATE_SAMPLE_MASK"},
2836 len = (data[0] & 0x0000ffff) + 2;
2838 opcode = (data[0] & 0xffff0000) >> 16;
2841 len = (data[0] & 0x000000ff) + 2;
2842 return i965_decode_urb_fence(data, hw_offset, len, count,
2845 instr_out(data, hw_offset, 0, "CS_URB_STATE\n");
2846 instr_out(data, hw_offset, 1,
2847 "entry_size: %d [%d bytes], n_entries: %d\n",
2848 (data[1] >> 4) & 0x1f,
2849 (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7);
2852 len = (data[0] & 0x000000ff) + 2;
2853 instr_out(data, hw_offset, 0, "CONSTANT_BUFFER: %s\n",
2854 (data[0] >> 8) & 1 ? "valid" : "invalid");
2855 instr_out(data, hw_offset, 1,
2856 "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f,
2857 ((data[1] & 0x3f) + 1) * 64);
2861 instr_out(data, hw_offset, 0, "STATE_BASE_ADDRESS\n");
2864 if (IS_GEN6(devid) || IS_GEN7(devid))
2866 else if (IS_GEN5(devid))
2871 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
2873 BUFFER_FAIL(count, len, "STATE_BASE_ADDRESS");
2875 state_base_out(data, hw_offset, i++, "general");
2876 state_base_out(data, hw_offset, i++, "surface");
2877 if (IS_GEN6(devid) || IS_GEN7(devid))
2878 state_base_out(data, hw_offset, i++, "dynamic");
2879 state_base_out(data, hw_offset, i++, "indirect");
2880 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2881 state_base_out(data, hw_offset, i++, "instruction");
2883 state_max_out(data, hw_offset, i++, "general");
2884 if (IS_GEN6(devid) || IS_GEN7(devid))
2885 state_max_out(data, hw_offset, i++, "dynamic");
2886 state_max_out(data, hw_offset, i++, "indirect");
2887 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2888 state_max_out(data, hw_offset, i++, "instruction");
2894 "Bad count in 3DSTATE_PIPELINED_POINTERS\n");
2896 BUFFER_FAIL(count, len, "3DSTATE_PIPELINED_POINTERS");
2898 instr_out(data, hw_offset, 0, "3DSTATE_PIPELINED_POINTERS\n");
2899 instr_out(data, hw_offset, 1, "VS state\n");
2900 instr_out(data, hw_offset, 2, "GS state\n");
2901 instr_out(data, hw_offset, 3, "Clip state\n");
2902 instr_out(data, hw_offset, 4, "SF state\n");
2903 instr_out(data, hw_offset, 5, "WM state\n");
2904 instr_out(data, hw_offset, 6, "CC state\n");
2907 len = (data[0] & 0x000000ff) + 2;
2908 if (len != 6 && len != 4)
2910 "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
2913 BUFFER_FAIL(count, len,
2914 "3DSTATE_BINDING_TABLE_POINTERS");
2915 instr_out(data, hw_offset, 0,
2916 "3DSTATE_BINDING_TABLE_POINTERS\n");
2917 instr_out(data, hw_offset, 1, "VS binding table\n");
2918 instr_out(data, hw_offset, 2, "GS binding table\n");
2919 instr_out(data, hw_offset, 3, "Clip binding table\n");
2920 instr_out(data, hw_offset, 4, "SF binding table\n");
2921 instr_out(data, hw_offset, 5, "WM binding table\n");
2924 BUFFER_FAIL(count, len,
2925 "3DSTATE_BINDING_TABLE_POINTERS");
2927 instr_out(data, hw_offset, 0,
2928 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
2929 "GS mod %d, PS mod %d\n",
2930 (data[0] & (1 << 8)) != 0,
2931 (data[0] & (1 << 9)) != 0,
2932 (data[0] & (1 << 12)) != 0);
2933 instr_out(data, hw_offset, 1, "VS binding table\n");
2934 instr_out(data, hw_offset, 2, "GS binding table\n");
2935 instr_out(data, hw_offset, 3, "WM binding table\n");
2940 len = (data[0] & 0xff) + 2;
2943 "Bad count in 3DSTATE_SAMPLER_STATE_POINTERS\n");
2945 BUFFER_FAIL(count, len,
2946 "3DSTATE_SAMPLER_STATE_POINTERS");
2947 instr_out(data, hw_offset, 0,
2948 "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
2949 "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
2950 (data[0] & (1 << 9)) != 0,
2951 (data[0] & (1 << 12)) != 0);
2952 instr_out(data, hw_offset, 1, "VS sampler state\n");
2953 instr_out(data, hw_offset, 2, "GS sampler state\n");
2954 instr_out(data, hw_offset, 3, "WM sampler state\n");
2957 len = (data[0] & 0xff) + 2;
2959 fprintf(out, "Bad count in 3DSTATE_URB\n");
2961 BUFFER_FAIL(count, len, "3DSTATE_URB");
2962 instr_out(data, hw_offset, 0, "3DSTATE_URB\n");
2963 instr_out(data, hw_offset, 1,
2964 "VS entries %d, alloc size %d (1024bit row)\n",
2965 data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1);
2966 instr_out(data, hw_offset, 2,
2967 "GS entries %d, alloc size %d (1024bit row)\n",
2968 (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1);
2972 len = (data[0] & 0xff) + 2;
2973 if ((len - 1) % 4 != 0)
2974 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
2976 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_BUFFERS");
2977 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_BUFFERS\n");
2979 for (i = 1; i < len;) {
2981 if (IS_GEN6(devid)) {
2988 instr_out(data, hw_offset, i,
2989 "buffer %d: %s, pitch %db\n", data[i] >> idx,
2990 data[i] & (1 << access) ? "random" :
2991 "sequential", data[i] & 0x07ff);
2993 instr_out(data, hw_offset, i++, "buffer address\n");
2994 instr_out(data, hw_offset, i++, "max index\n");
2995 instr_out(data, hw_offset, i++, "mbz\n");
3000 len = (data[0] & 0xff) + 2;
3001 if ((len + 1) % 2 != 0)
3002 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
3004 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_ELEMENTS");
3005 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_ELEMENTS\n");
3007 for (i = 1; i < len;) {
3008 instr_out(data, hw_offset, i,
3009 "buffer %d: %svalid, type 0x%04x, "
3010 "src offset 0x%04x bytes\n",
3011 data[i] >> (IS_GEN6(devid) ? 26 : 27),
3012 data[i] & (1 << (IS_GEN6(devid) ? 25 : 26)) ?
3013 "" : "in", (data[i] >> 16) & 0x1ff,
3016 instr_out(data, hw_offset, i, "(%s, %s, %s, %s), "
3017 "dst offset 0x%02x bytes\n",
3018 get_965_element_component(data[i], 0),
3019 get_965_element_component(data[i], 1),
3020 get_965_element_component(data[i], 2),
3021 get_965_element_component(data[i], 3),
3022 (data[i] & 0xff) * 4);
3028 len = (data[0] & 0xff) + 2;
3031 "Bad count in 3DSTATE_VIEWPORT_STATE_POINTERS\n");
3033 BUFFER_FAIL(count, len,
3034 "3DSTATE_VIEWPORT_STATE_POINTERS");
3035 instr_out(data, hw_offset, 0,
3036 "3DSTATE_VIEWPORT_STATE_POINTERS\n");
3037 instr_out(data, hw_offset, 1, "clip\n");
3038 instr_out(data, hw_offset, 2, "sf\n");
3039 instr_out(data, hw_offset, 3, "cc\n");
3043 len = (data[0] & 0xff) + 2;
3045 fprintf(out, "Bad count in 3DSTATE_INDEX_BUFFER\n");
3047 BUFFER_FAIL(count, len, "3DSTATE_INDEX_BUFFER");
3048 instr_out(data, hw_offset, 0, "3DSTATE_INDEX_BUFFER\n");
3049 instr_out(data, hw_offset, 1, "beginning buffer address\n");
3050 instr_out(data, hw_offset, 2, "ending buffer address\n");
3054 len = (data[0] & 0xff) + 2;
3057 "Bad count in 3DSTATE_CC_STATE_POINTERS\n");
3059 BUFFER_FAIL(count, len, "3DSTATE_CC_STATE_POINTERS");
3060 instr_out(data, hw_offset, 0, "3DSTATE_CC_STATE_POINTERS\n");
3061 instr_out(data, hw_offset, 1, "blend change %d\n", data[1] & 1);
3062 instr_out(data, hw_offset, 2, "depth stencil change %d\n",
3064 instr_out(data, hw_offset, 3, "cc change %d\n", data[3] & 1);
3068 len = (data[0] & 0xff) + 2;
3070 fprintf(out, "Bad count in 3DSTATE_SCISSOR_POINTERS\n");
3072 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_POINTERS");
3073 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_POINTERS\n");
3074 instr_out(data, hw_offset, 1, "scissor rect offset\n");
3078 len = (data[0] & 0xff) + 2;
3080 fprintf(out, "Bad count in 3DSTATE_VS\n");
3082 BUFFER_FAIL(count, len, "3DSTATE_VS");
3083 instr_out(data, hw_offset, 0, "3DSTATE_VS\n");
3084 instr_out(data, hw_offset, 1, "kernel pointer\n");
3085 instr_out(data, hw_offset, 2,
3086 "SPF=%d, VME=%d, Sampler Count %d, "
3087 "Binding table count %d\n", (data[2] >> 31) & 1,
3088 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3089 (data[2] >> 18) & 0xff);
3090 instr_out(data, hw_offset, 3, "scratch offset\n");
3091 instr_out(data, hw_offset, 4,
3092 "Dispatch GRF start %d, VUE read length %d, "
3093 "VUE read offset %d\n", (data[4] >> 20) & 0x1f,
3094 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3095 instr_out(data, hw_offset, 5,
3096 "Max Threads %d, Vertex Cache %sable, "
3097 "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1,
3098 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
3099 (data[5] & 1) != 0 ? "en" : "dis");
3103 len = (data[0] & 0xff) + 2;
3105 fprintf(out, "Bad count in 3DSTATE_GS\n");
3107 BUFFER_FAIL(count, len, "3DSTATE_GS");
3108 instr_out(data, hw_offset, 0, "3DSTATE_GS\n");
3109 instr_out(data, hw_offset, 1, "kernel pointer\n");
3110 instr_out(data, hw_offset, 2,
3111 "SPF=%d, VME=%d, Sampler Count %d, "
3112 "Binding table count %d\n", (data[2] >> 31) & 1,
3113 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3114 (data[2] >> 18) & 0xff);
3115 instr_out(data, hw_offset, 3, "scratch offset\n");
3116 instr_out(data, hw_offset, 4,
3117 "Dispatch GRF start %d, VUE read length %d, "
3118 "VUE read offset %d\n", (data[4] & 0xf),
3119 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3120 instr_out(data, hw_offset, 5,
3121 "Max Threads %d, Rendering %sable\n",
3122 ((data[5] >> 25) & 0x7f) + 1,
3123 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
3124 instr_out(data, hw_offset, 6,
3125 "Reorder %sable, Discard Adjaceny %sable, "
3127 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
3128 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
3129 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
3133 len = (data[0] & 0xff) + 2;
3135 fprintf(out, "Bad count in 3DSTATE_CLIP\n");
3137 BUFFER_FAIL(count, len, "3DSTATE_CLIP");
3138 instr_out(data, hw_offset, 0, "3DSTATE_CLIP\n");
3139 instr_out(data, hw_offset, 1,
3140 "UserClip distance cull test mask 0x%x\n",
3142 instr_out(data, hw_offset, 2,
3143 "Clip %sable, API mode %s, Viewport XY test %sable, "
3144 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
3145 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
3146 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
3147 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
3148 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
3149 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
3150 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
3151 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
3152 (data[2] >> 13) & 7,
3153 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
3154 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
3155 (data[2] >> 4) & 3, (data[2] >> 2) & 3,
3157 instr_out(data, hw_offset, 3,
3158 "Min PointWidth %d, Max PointWidth %d, "
3159 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
3160 (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff,
3161 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
3166 len = (data[0] & 0xff) + 2;
3168 fprintf(out, "Bad count in 3DSTATE_SF\n");
3170 BUFFER_FAIL(count, len, "3DSTATE_SF");
3171 instr_out(data, hw_offset, 0, "3DSTATE_SF\n");
3172 instr_out(data, hw_offset, 1,
3173 "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
3174 "VUE read offset %d\n", (data[1] >> 22) & 0x3f,
3175 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
3176 (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f);
3177 instr_out(data, hw_offset, 2,
3178 "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
3179 "VP transform %sable, FrontWinding_%s\n",
3180 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
3181 (data[2] >> 5) & 3, (data[2] >> 3) & 3,
3182 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
3183 (data[2] & 1) != 0 ? "CCW" : "CW");
3184 instr_out(data, hw_offset, 3,
3185 "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
3186 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
3187 (data[3] >> 29) & 3,
3188 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
3189 (data[3] >> 8) & 3);
3190 instr_out(data, hw_offset, 4,
3191 "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
3192 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
3193 (data[4] & (1 << 12)) != 0 ? 4 : 8,
3194 (data[4] & (1 << 11)) != 0);
3195 instr_out(data, hw_offset, 5,
3196 "Global Depth Offset Constant %f\n",
3197 *(float *)(&data[5]));
3198 instr_out(data, hw_offset, 6, "Global Depth Offset Scale %f\n",
3199 *(float *)(&data[6]));
3200 instr_out(data, hw_offset, 7, "Global Depth Offset Clamp %f\n",
3201 *(float *)(&data[7]));
3203 for (i = 0, j = 0; i < 8; i++, j += 2)
3204 instr_out(data, hw_offset, i + 8,
3205 "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, "
3206 "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n",
3208 (data[8 + i] & (1 << 31)) != 0 ? "W" : "",
3209 (data[8 + i] & (1 << 30)) != 0 ? "Z" : "",
3210 (data[8 + i] & (1 << 29)) != 0 ? "Y" : "",
3211 (data[8 + i] & (1 << 28)) != 0 ? "X" : "",
3212 (data[8 + i] >> 25) & 3,
3213 (data[8 + i] >> 22) & 3,
3214 (data[8 + i] >> 16) & 0x1f, j,
3215 (data[8 + i] & (1 << 15)) != 0 ? "W" : "",
3216 (data[8 + i] & (1 << 14)) != 0 ? "Z" : "",
3217 (data[8 + i] & (1 << 13)) != 0 ? "Y" : "",
3218 (data[8 + i] & (1 << 12)) != 0 ? "X" : "",
3219 (data[8 + i] >> 9) & 3,
3220 (data[8 + i] >> 6) & 3, (data[8 + i] & 0x1f));
3221 instr_out(data, hw_offset, 16,
3222 "Point Sprite TexCoord Enable\n");
3223 instr_out(data, hw_offset, 17, "Const Interp Enable\n");
3224 instr_out(data, hw_offset, 18,
3225 "Attrib 7-0 WrapShortest Enable\n");
3226 instr_out(data, hw_offset, 19,
3227 "Attrib 15-8 WrapShortest Enable\n");
3232 len = (data[0] & 0xff) + 2;
3234 fprintf(out, "Bad count in 3DSTATE_WM\n");
3236 BUFFER_FAIL(count, len, "3DSTATE_WM");
3237 instr_out(data, hw_offset, 0, "3DSTATE_WM\n");
3238 instr_out(data, hw_offset, 1, "kernel start pointer 0\n");
3239 instr_out(data, hw_offset, 2,
3240 "SPF=%d, VME=%d, Sampler Count %d, "
3241 "Binding table count %d\n", (data[2] >> 31) & 1,
3242 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3243 (data[2] >> 18) & 0xff);
3244 instr_out(data, hw_offset, 3, "scratch offset\n");
3245 instr_out(data, hw_offset, 4,
3246 "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
3247 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
3248 (data[4] & (1 << 30)) != 0,
3249 (data[4] & (1 << 28)) != 0,
3250 (data[4] & (1 << 27)) != 0, (data[4] >> 16) & 0x7f,
3251 (data[4] >> 8) & 0x7f, (data[4] & 0x7f));
3252 instr_out(data, hw_offset, 5,
3253 "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
3254 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, Dispatch32 %d, "
3255 "Dispatch16 %d, Dispatch8 %d\n",
3256 ((data[5] >> 25) & 0x7f) + 1,
3257 (data[5] & (1 << 22)) != 0,
3258 (data[5] & (1 << 21)) != 0,
3259 (data[5] & (1 << 20)) != 0,
3260 (data[5] & (1 << 19)) != 0, (data[5] & (1 << 8)) != 0,
3261 (data[5] & (1 << 2)) != 0, (data[5] & (1 << 1)) != 0,
3262 (data[5] & (1 << 0)) != 0);
3263 instr_out(data, hw_offset, 6,
3264 "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
3265 "Barycentric interp mode 0x%x, Point raster rule %d, Multisample mode %d, "
3266 "Multisample Dispatch mode %d\n",
3267 (data[6] >> 20) & 0x3f, (data[6] >> 18) & 3,
3268 (data[6] >> 16) & 3, (data[6] >> 10) & 0x3f,
3269 (data[6] & (1 << 9)) != 0, (data[6] >> 1) & 3,
3271 instr_out(data, hw_offset, 7, "kernel start pointer 1\n");
3272 instr_out(data, hw_offset, 8, "kernel start pointer 2\n");
3279 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
3281 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
3283 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
3284 instr_out(data, hw_offset, 1, "top left: %d,%d\n",
3285 data[1] & 0xffff, (data[1] >> 16) & 0xffff);
3286 instr_out(data, hw_offset, 2, "bottom right: %d,%d\n",
3287 data[2] & 0xffff, (data[2] >> 16) & 0xffff);
3288 instr_out(data, hw_offset, 3, "origin: %d,%d\n",
3289 (int)data[3] & 0xffff, ((int)data[3] >> 16) & 0xffff);
3294 if (len < 5 || len > 7)
3295 fprintf(out, "Bad count in 3DSTATE_DEPTH_BUFFER\n");
3297 BUFFER_FAIL(count, len, "3DSTATE_DEPTH_BUFFER");
3299 instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_BUFFER\n");
3300 if (IS_GEN5(devid) || IS_GEN6(devid))
3301 instr_out(data, hw_offset, 1,
3302 "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
3303 get_965_surfacetype(data[1] >> 29),
3304 get_965_depthformat((data[1] >> 18) & 0x7),
3305 (data[1] & 0x0001ffff) + 1,
3306 data[1] & (1 << 27) ? "" : "not ",
3307 (data[1] & (1 << 22)) != 0,
3308 (data[1] & (1 << 21)) != 0);
3310 instr_out(data, hw_offset, 1,
3311 "%s, %s, pitch = %d bytes, %stiled\n",
3312 get_965_surfacetype(data[1] >> 29),
3313 get_965_depthformat((data[1] >> 18) & 0x7),
3314 (data[1] & 0x0001ffff) + 1,
3315 data[1] & (1 << 27) ? "" : "not ");
3316 instr_out(data, hw_offset, 2, "depth offset\n");
3317 instr_out(data, hw_offset, 3, "%dx%d\n",
3318 ((data[3] & 0x0007ffc0) >> 6) + 1,
3319 ((data[3] & 0xfff80000) >> 19) + 1);
3320 instr_out(data, hw_offset, 4, "volume depth\n");
3322 instr_out(data, hw_offset, 5, "\n");
3325 instr_out(data, hw_offset, 6, "\n");
3327 instr_out(data, hw_offset, 6,
3328 "render target view extent\n");
3334 if (IS_GEN6(devid) || IS_GEN7(devid)) {
3336 len = (data[0] & 0xff) + 2;
3337 if (len != 4 && len != 5)
3338 fprintf(out, "Bad count in PIPE_CONTROL\n");
3340 BUFFER_FAIL(count, len, "PIPE_CONTROL");
3342 switch ((data[1] >> 14) & 0x3) {
3347 desc1 = "qword write";
3350 desc1 = "PS_DEPTH_COUNT write";
3353 desc1 = "TIMESTAMP write";
3356 instr_out(data, hw_offset, 0, "PIPE_CONTROL\n");
3357 instr_out(data, hw_offset, 1,
3358 "%s, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
3360 data[1] & (1 << 20) ? "cs stall, " : "",
3361 data[1] & (1 << 19) ?
3362 "global snapshot count reset, " : "",
3363 data[1] & (1 << 18) ? "tlb invalidate, " : "",
3364 data[1] & (1 << 17) ? "gfdt flush, " : "",
3365 data[1] & (1 << 17) ? "media state clear, " :
3367 data[1] & (1 << 13) ? "depth stall, " : "",
3368 data[1] & (1 << 12) ?
3369 "render target cache flush, " : "",
3370 data[1] & (1 << 11) ?
3371 "instruction cache invalidate, " : "",
3372 data[1] & (1 << 10) ?
3373 "texture cache invalidate, " : "",
3374 data[1] & (1 << 9) ?
3375 "indirect state invalidate, " : "",
3376 data[1] & (1 << 8) ? "notify irq, " : "",
3377 data[1] & (1 << 7) ? "PIPE_CONTROL flush, " :
3379 data[1] & (1 << 6) ? "protect mem app_id, " :
3380 "", data[1] & (1 << 5) ? "DC flush, " : "",
3381 data[1] & (1 << 4) ? "vf fetch invalidate, " :
3383 data[1] & (1 << 3) ?
3384 "constant cache invalidate, " : "",
3385 data[1] & (1 << 2) ?
3386 "state cache invalidate, " : "",
3387 data[1] & (1 << 1) ? "stall at scoreboard, " :
3389 data[1] & (1 << 0) ? "depth cache flush, " :
3392 instr_out(data, hw_offset, 2,
3393 "destination address\n");
3394 instr_out(data, hw_offset, 3,
3395 "immediate dword low\n");
3396 instr_out(data, hw_offset, 4,
3397 "immediate dword high\n");
3399 for (i = 2; i < len; i++) {
3400 instr_out(data, hw_offset, i, "\n");
3405 len = (data[0] & 0xff) + 2;
3407 fprintf(out, "Bad count in PIPE_CONTROL\n");
3409 BUFFER_FAIL(count, len, "PIPE_CONTROL");
3411 switch ((data[0] >> 14) & 0x3) {
3416 desc1 = "qword write";
3419 desc1 = "PS_DEPTH_COUNT write";
3422 desc1 = "TIMESTAMP write";
3425 instr_out(data, hw_offset, 0,
3426 "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, "
3429 data[0] & (1 << 13) ? "" : "no ",
3430 data[0] & (1 << 12) ? "" : "no ",
3431 data[0] & (1 << 11) ? "" : "no ");
3432 instr_out(data, hw_offset, 1, "destination address\n");
3433 instr_out(data, hw_offset, 2, "immediate dword low\n");
3434 instr_out(data, hw_offset, 3, "immediate dword high\n");
3438 len = (data[0] & 0xff) + 2;
3440 fprintf(out, "Bad count in 3DPRIMITIVE\n");
3442 BUFFER_FAIL(count, len, "3DPRIMITIVE");
3444 instr_out(data, hw_offset, 0,
3445 "3DPRIMITIVE: %s %s\n",
3446 get_965_prim_type(data[0]),
3447 (data[0] & (1 << 15)) ? "random" : "sequential");
3448 instr_out(data, hw_offset, 1, "vertex count\n");
3449 instr_out(data, hw_offset, 2, "start vertex\n");
3450 instr_out(data, hw_offset, 3, "instance count\n");
3451 instr_out(data, hw_offset, 4, "start instance\n");
3452 instr_out(data, hw_offset, 5, "index bias\n");
3456 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3457 opcode_3d = &opcodes_3d[idx];
3458 if ((data[0] & 0xffff0000) >> 16 == opcode_3d->opcode) {
3462 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
3463 if (opcode_3d->max_len > 1) {
3464 len = (data[0] & 0xff) + 2;
3465 if (len < opcode_3d->min_len ||
3466 len > opcode_3d->max_len) {
3467 fprintf(out, "Bad count in %s\n",
3472 for (i = 1; i < len; i++) {
3474 BUFFER_FAIL(count, len,
3476 instr_out(data, hw_offset, i, "dword %d\n", i);
3482 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n",
3489 decode_3d_i830(uint32_t *data, uint32_t count, uint32_t hw_offset, uint32_t devid,
3497 unsigned int min_len;
3498 unsigned int max_len;
3501 { 0x02, 1, 1, "3DSTATE_MODES_3" },
3502 { 0x03, 1, 1, "3DSTATE_ENABLES_1" },
3503 { 0x04, 1, 1, "3DSTATE_ENABLES_2" },
3504 { 0x05, 1, 1, "3DSTATE_VFT0" },
3505 { 0x06, 1, 1, "3DSTATE_AA" },
3506 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
3507 { 0x08, 1, 1, "3DSTATE_MODES_1" },
3508 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
3509 { 0x0a, 1, 1, "3DSTATE_VFT1" },
3510 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
3511 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
3512 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
3513 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
3514 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
3515 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
3516 { 0x16, 1, 1, "3DSTATE_MODES_4"},
3519 opcode = (data[0] & 0x1f000000) >> 24;
3523 return decode_3d_primitive(data, count, hw_offset, failures);
3525 return decode_3d_1d(data, count, hw_offset, devid, failures);
3527 return decode_3d_1c(data, count, hw_offset, failures);
3530 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3531 opcode_3d = &opcodes_3d[idx];
3532 if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) {
3533 unsigned int len = 1, i;
3535 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
3536 if (opcode_3d->max_len > 1) {
3537 len = (data[0] & 0xff) + 2;
3538 if (len < opcode_3d->min_len ||
3539 len > opcode_3d->max_len) {
3540 fprintf(out, "Bad count in %s\n",
3545 for (i = 1; i < len; i++) {
3547 BUFFER_FAIL(count, len,
3549 instr_out(data, hw_offset, i, "dword %d\n", i);
3555 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n",
3561 struct drm_intel_decode *
3562 drm_intel_decode_context_alloc(uint32_t devid)
3564 struct drm_intel_decode *ctx;
3566 ctx = calloc(1, sizeof(struct drm_intel_decode));
3577 drm_intel_decode_context_free(struct drm_intel_decode *ctx)
3583 drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
3586 ctx->dump_past_end = !!dump_past_end;
3590 drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx,
3591 void *data, uint32_t hw_offset, int count)
3593 ctx->base_data = data;
3594 ctx->base_hw_offset = hw_offset;
3595 ctx->base_count = count;
3599 drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
3600 uint32_t head, uint32_t tail)
3607 drm_intel_decode_set_output_file(struct drm_intel_decode *ctx,
3614 * Decodes an i830-i915 batch buffer, writing the output to stdout.
3616 * \param data batch buffer contents
3617 * \param count number of DWORDs to decode in the batch buffer
3618 * \param hw_offset hardware address for the buffer
3621 drm_intel_decode(struct drm_intel_decode *ctx)
3624 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->data, ctx->count,
3649 ctx->hw_offset, &failures);
3651 /* If MI_BATCHBUFFER_END happened, then dump
3652 * the rest of the output in case we some day
3653 * want it in debugging, but don't decode it
3654 * since it'll just confuse in the common
3658 if (ctx->dump_past_end) {
3661 for (index = index + 1; index < ctx->count;
3663 instr_out(ctx->data,
3672 index += decode_2d(ctx->data, ctx->count,
3673 ctx->hw_offset, &failures);
3676 if (IS_9XX(devid) && !IS_GEN3(devid)) {
3678 decode_3d_965(ctx->data, ctx->count,
3679 ctx->hw_offset, devid,
3681 } else if (IS_GEN3(devid)) {
3682 index += decode_3d(ctx->data, ctx->count,
3687 decode_3d_i830(ctx->data, ctx->count,
3688 ctx->hw_offset, devid,
3693 instr_out(ctx->data, ctx->hw_offset, index,
3701 if (ctx->count < index)
3704 ctx->count -= index;
3706 ctx->hw_offset += 4 * index;