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_decode.h"
32 #include "intel_chipset.h"
33 #include "intel_bufmgr.h"
35 /* Struct for tracking drm_intel_decode state. */
36 struct drm_intel_decode {
40 /** GPU address of the start of the batchbuffer data. */
42 /** CPU Virtual address of the start of the batchbuffer data. */
44 /** Number of DWORDs of batchbuffer data. */
48 * GPU head and tail pointers, which will be noted in the dump, or ~0.
54 * Whether to dump the dwords after MI_BATCHBUFFER_END.
56 * This sometimes provides clues in corrupted batchbuffers,
57 * and is used by the intel-gpu-tools.
63 static uint32_t saved_s2 = 0, saved_s4 = 0;
64 static char saved_s2_set = 0, saved_s4_set = 0;
65 static uint32_t head_offset = 0xffffffff; /* undefined */
66 static uint32_t tail_offset = 0xffffffff; /* undefined */
69 #define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0]))
72 #define BUFFER_FAIL(_count, _len, _name) do { \
73 fprintf(out, "Buffer size too small in %s (%d < %d)\n", \
74 (_name), (_count), (_len)); \
79 static float int_as_float(uint32_t intval)
91 instr_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
95 const char *parseinfo;
96 uint32_t offset = hw_offset + index * 4;
98 if (offset == head_offset)
100 else if (offset == tail_offset)
105 fprintf(out, "0x%08x: %s 0x%08x: %s", offset, parseinfo,
106 data[index], index == 0 ? "" : " ");
108 vfprintf(out, fmt, va);
113 decode_mi(uint32_t *data, uint32_t count, uint32_t hw_offset, int *failures)
115 unsigned int opcode, len = -1;
116 const char *post_sync_op = "";
121 unsigned int min_len;
122 unsigned int max_len;
125 { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" },
126 { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" },
127 { 0x30, 0x3f, 3, 3, "MI_BATCH_BUFFER" },
128 { 0x31, 0x3f, 2, 2, "MI_BATCH_BUFFER_START" },
129 { 0x14, 0x3f, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
130 { 0x04, 0, 1, 1, "MI_FLUSH" },
131 { 0x22, 0x1f, 3, 3, "MI_LOAD_REGISTER_IMM" },
132 { 0x13, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
133 { 0x12, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
134 { 0x00, 0, 1, 1, "MI_NOOP" },
135 { 0x11, 0x3f, 2, 2, "MI_OVERLAY_FLIP" },
136 { 0x07, 0, 1, 1, "MI_REPORT_HEAD" },
137 { 0x18, 0x3f, 2, 2, "MI_SET_CONTEXT" },
138 { 0x20, 0x3f, 3, 4, "MI_STORE_DATA_IMM" },
139 { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" },
140 { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" },
141 { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" },
142 { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT" },
143 { 0x16, 0x7f, 3, 3, "MI_SEMAPHORE_MBOX" },
144 { 0x26, 0x1f, 3, 4, "MI_FLUSH_DW" },
145 { 0x0b, 0, 1, 1, "MI_SUSPEND_FLUSH"},
148 /* check instruction length */
149 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
151 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
153 if (opcodes_mi[opcode].max_len > 1) {
155 (data[0] & opcodes_mi[opcode].len_mask) + 2;
156 if (len < opcodes_mi[opcode].min_len
157 || len > opcodes_mi[opcode].max_len) {
159 "Bad length (%d) in %s, [%d, %d]\n",
160 len, opcodes_mi[opcode].name,
161 opcodes_mi[opcode].min_len,
162 opcodes_mi[opcode].max_len);
169 switch ((data[0] & 0x1f800000) >> 23) {
171 instr_out(data, hw_offset, 0, "MI_BATCH_BUFFER_END\n");
174 instr_out(data, hw_offset, 0, "MI_SEMAPHORE_MBOX%s%s%s%s %u\n",
175 data[0] & (1 << 22) ? " global gtt," : "",
176 data[0] & (1 << 21) ? " update semaphore," : "",
177 data[0] & (1 << 20) ? " compare semaphore," : "",
178 data[0] & (1 << 18) ? " use compare reg" : "",
179 (data[0] & (0x3 << 16)) >> 16);
180 instr_out(data, hw_offset, 1, "value\n");
181 instr_out(data, hw_offset, 2, "address\n");
184 instr_out(data, hw_offset, 0, "MI_STORE_DATA_INDEX%s\n",
185 data[0] & (1 << 21) ? " use per-process HWS," : "");
186 instr_out(data, hw_offset, 1, "index\n");
187 instr_out(data, hw_offset, 2, "dword\n");
189 instr_out(data, hw_offset, 3, "upper dword\n");
192 if (data[0] & (1 << 22))
193 instr_out(data, hw_offset, 0,
194 "MI_NOOP write NOPID reg, val=0x%x\n",
195 data[0] & ((1 << 22) - 1));
197 instr_out(data, hw_offset, 0, "MI_NOOP\n");
200 switch (data[0] & (0x3 << 14)) {
202 post_sync_op = "no write";
205 post_sync_op = "write data";
208 post_sync_op = "reserved";
211 post_sync_op = "write TIMESTAMP";
214 instr_out(data, hw_offset, 0,
215 "MI_FLUSH_DW%s%s%s%s post_sync_op='%s' %s%s\n",
216 data[0] & (1 << 22) ?
217 " enable protected mem (BCS-only)," : "",
218 data[0] & (1 << 21) ? " store in hws," : "",
219 data[0] & (1 << 18) ? " invalidate tlb," : "",
220 data[0] & (1 << 17) ? " flush gfdt," : "",
222 data[0] & (1 << 8) ? " enable notify interrupt," : "",
224 " invalidate video state (BCS-only)," : "");
225 if (data[0] & (1 << 21))
226 instr_out(data, hw_offset, 1, "hws index\n");
228 instr_out(data, hw_offset, 1, "address\n");
229 instr_out(data, hw_offset, 2, "dword\n");
231 instr_out(data, hw_offset, 3, "upper dword\n");
235 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
237 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
240 instr_out(data, hw_offset, 0, "%s\n",
241 opcodes_mi[opcode].name);
242 for (i = 1; i < len; i++) {
244 BUFFER_FAIL(count, len,
245 opcodes_mi[opcode].name);
246 instr_out(data, hw_offset, i, "dword %d\n", i);
253 instr_out(data, hw_offset, 0, "MI UNKNOWN\n");
259 decode_2d_br00(uint32_t *data, uint32_t count, uint32_t hw_offset,
262 instr_out(data, hw_offset, 0,
263 "%s (rgb %sabled, alpha %sabled, src tile %d, dst tile %d)\n",
265 (data[count] & (1 << 20)) ? "en" : "dis",
266 (data[count] & (1 << 21)) ? "en" : "dis",
267 (data[count] >> 15) & 1, (data[count] >> 11) & 1);
270 static void decode_2d_br01(uint32_t *data, uint32_t count, uint32_t hw_offset)
273 switch ((data[count] >> 24) & 0x3) {
288 instr_out(data, hw_offset, count, "format %s, pitch %d, rop 0x%02x, "
289 "clipping %sabled, %s%s \n",
291 (short)(data[count] & 0xffff),
292 (data[count] >> 16) & 0xff,
293 data[count] & (1 << 30) ? "en" : "dis",
294 data[count] & (1 << 31) ? "solid pattern enabled, " : "",
295 data[count] & (1 << 31) ?
296 "mono pattern transparency enabled, " : "");
301 decode_2d(uint32_t *data, uint32_t count, uint32_t hw_offset, int *failures)
303 unsigned int opcode, len;
307 unsigned int min_len;
308 unsigned int max_len;
311 { 0x40, 5, 5, "COLOR_BLT" },
312 { 0x43, 6, 6, "SRC_COPY_BLT" },
313 { 0x01, 8, 8, "XY_SETUP_BLT" },
314 { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
315 { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
316 { 0x24, 2, 2, "XY_PIXEL_BLT" },
317 { 0x25, 3, 3, "XY_SCANLINES_BLT" },
318 { 0x26, 4, 4, "Y_TEXT_BLT" },
319 { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
320 { 0x50, 6, 6, "XY_COLOR_BLT" },
321 { 0x51, 6, 6, "XY_PAT_BLT" },
322 { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
323 { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
324 { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
325 { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
326 { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
327 { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
328 { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
329 { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
330 { 0x55, 9, 9, "XY_FULL_BLT" },
331 { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
332 { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
333 { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
334 { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
335 { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT"},
338 switch ((data[0] & 0x1fc00000) >> 22) {
340 instr_out(data, hw_offset, 0,
341 "XY_SCANLINES_BLT (pattern seed (%d, %d), dst tile %d)\n",
342 (data[0] >> 12) & 0x8,
343 (data[0] >> 8) & 0x8, (data[0] >> 11) & 1);
345 len = (data[0] & 0x000000ff) + 2;
347 fprintf(out, "Bad count in XY_SCANLINES_BLT\n");
349 BUFFER_FAIL(count, len, "XY_SCANLINES_BLT");
351 instr_out(data, hw_offset, 1, "dest (%d,%d)\n",
352 data[1] & 0xffff, data[1] >> 16);
353 instr_out(data, hw_offset, 2, "dest (%d,%d)\n",
354 data[2] & 0xffff, data[2] >> 16);
357 decode_2d_br00(data, 0, hw_offset, "XY_SETUP_BLT");
359 len = (data[0] & 0x000000ff) + 2;
361 fprintf(out, "Bad count in XY_SETUP_BLT\n");
363 BUFFER_FAIL(count, len, "XY_SETUP_BLT");
365 decode_2d_br01(data, 1, hw_offset);
366 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
367 data[2] & 0xffff, data[2] >> 16);
368 instr_out(data, hw_offset, 3, "cliprect (%d,%d)\n",
369 data[3] & 0xffff, data[3] >> 16);
370 instr_out(data, hw_offset, 4, "setup dst offset 0x%08x\n",
372 instr_out(data, hw_offset, 5, "setup background color\n");
373 instr_out(data, hw_offset, 6, "setup foreground color\n");
374 instr_out(data, hw_offset, 7, "color pattern offset\n");
377 decode_2d_br00(data, 0, hw_offset, "XY_SETUP_CLIP_BLT");
379 len = (data[0] & 0x000000ff) + 2;
381 fprintf(out, "Bad count in XY_SETUP_CLIP_BLT\n");
383 BUFFER_FAIL(count, len, "XY_SETUP_CLIP_BLT");
385 instr_out(data, hw_offset, 1, "cliprect (%d,%d)\n",
386 data[1] & 0xffff, data[2] >> 16);
387 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
388 data[2] & 0xffff, data[3] >> 16);
391 decode_2d_br00(data, 0, hw_offset,
392 "XY_SETUP_MONO_PATTERN_SL_BLT");
394 len = (data[0] & 0x000000ff) + 2;
397 "Bad count in XY_SETUP_MONO_PATTERN_SL_BLT\n");
399 BUFFER_FAIL(count, len, "XY_SETUP_MONO_PATTERN_SL_BLT");
401 decode_2d_br01(data, 1, hw_offset);
402 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
403 data[2] & 0xffff, data[2] >> 16);
404 instr_out(data, hw_offset, 3, "cliprect (%d,%d)\n",
405 data[3] & 0xffff, data[3] >> 16);
406 instr_out(data, hw_offset, 4, "setup dst offset 0x%08x\n",
408 instr_out(data, hw_offset, 5, "setup background color\n");
409 instr_out(data, hw_offset, 6, "setup foreground color\n");
410 instr_out(data, hw_offset, 7, "mono pattern dw0\n");
411 instr_out(data, hw_offset, 8, "mono pattern dw1\n");
414 decode_2d_br00(data, 0, hw_offset, "XY_COLOR_BLT");
416 len = (data[0] & 0x000000ff) + 2;
418 fprintf(out, "Bad count in XY_COLOR_BLT\n");
420 BUFFER_FAIL(count, len, "XY_COLOR_BLT");
422 decode_2d_br01(data, 1, hw_offset);
423 instr_out(data, hw_offset, 2, "(%d,%d)\n",
424 data[2] & 0xffff, data[2] >> 16);
425 instr_out(data, hw_offset, 3, "(%d,%d)\n",
426 data[3] & 0xffff, data[3] >> 16);
427 instr_out(data, hw_offset, 4, "offset 0x%08x\n", data[4]);
428 instr_out(data, hw_offset, 5, "color\n");
431 decode_2d_br00(data, 0, hw_offset, "XY_SRC_COPY_BLT");
433 len = (data[0] & 0x000000ff) + 2;
435 fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
437 BUFFER_FAIL(count, len, "XY_SRC_COPY_BLT");
439 decode_2d_br01(data, 1, hw_offset);
440 instr_out(data, hw_offset, 2, "dst (%d,%d)\n",
441 data[2] & 0xffff, data[2] >> 16);
442 instr_out(data, hw_offset, 3, "dst (%d,%d)\n",
443 data[3] & 0xffff, data[3] >> 16);
444 instr_out(data, hw_offset, 4, "dst offset 0x%08x\n", data[4]);
445 instr_out(data, hw_offset, 5, "src (%d,%d)\n",
446 data[5] & 0xffff, data[5] >> 16);
447 instr_out(data, hw_offset, 6, "src pitch %d\n",
448 (short)(data[6] & 0xffff));
449 instr_out(data, hw_offset, 7, "src offset 0x%08x\n", data[7]);
453 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
455 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
459 instr_out(data, hw_offset, 0, "%s\n",
460 opcodes_2d[opcode].name);
461 if (opcodes_2d[opcode].max_len > 1) {
462 len = (data[0] & 0x000000ff) + 2;
463 if (len < opcodes_2d[opcode].min_len ||
464 len > opcodes_2d[opcode].max_len) {
465 fprintf(out, "Bad count in %s\n",
466 opcodes_2d[opcode].name);
470 for (i = 1; i < len; i++) {
472 BUFFER_FAIL(count, len,
473 opcodes_2d[opcode].name);
474 instr_out(data, hw_offset, i, "dword %d\n", i);
481 instr_out(data, hw_offset, 0, "2D UNKNOWN\n");
487 decode_3d_1c(uint32_t *data, uint32_t count, uint32_t hw_offset, int *failures)
491 opcode = (data[0] & 0x00f80000) >> 19;
495 instr_out(data, hw_offset, 0,
496 "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n");
499 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_ENABLE %s\n",
500 data[0] & 1 ? "enabled" : "disabled");
503 instr_out(data, hw_offset, 0, "3DSTATE_MAP_COORD_SET_I830\n");
506 instr_out(data, hw_offset, 0, "3DSTATE_MAP_CUBE_I830\n");
509 instr_out(data, hw_offset, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
513 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n",
519 /** Sets the string dstname to describe the destination of the PS instruction */
521 i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask)
523 uint32_t a0 = data[i];
524 int dst_nr = (a0 >> 14) & 0xf;
529 if (((a0 >> 10) & 0xf) == 0xf) {
532 int dstmask_index = 0;
534 dstmask[dstmask_index++] = '.';
536 dstmask[dstmask_index++] = 'x';
538 dstmask[dstmask_index++] = 'y';
540 dstmask[dstmask_index++] = 'z';
542 dstmask[dstmask_index++] = 'w';
543 dstmask[dstmask_index++] = 0;
555 switch ((a0 >> 19) & 0x7) {
558 fprintf(out, "bad destination reg R%d\n", dst_nr);
559 sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
563 fprintf(out, "bad destination reg oC%d\n", dst_nr);
564 sprintf(dstname, "oC%s%s", dstmask, sat);
568 fprintf(out, "bad destination reg oD%d\n", dst_nr);
569 sprintf(dstname, "oD%s%s", dstmask, sat);
573 fprintf(out, "bad destination reg U%d\n", dst_nr);
574 sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
577 sprintf(dstname, "RESERVED");
583 i915_get_channel_swizzle(uint32_t select)
585 switch (select & 0x7) {
587 return (select & 8) ? "-x" : "x";
589 return (select & 8) ? "-y" : "y";
591 return (select & 8) ? "-z" : "z";
593 return (select & 8) ? "-w" : "w";
595 return (select & 8) ? "-0" : "0";
597 return (select & 8) ? "-1" : "1";
599 return (select & 8) ? "-bad" : "bad";
604 i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
608 sprintf(name, "R%d", src_nr);
610 fprintf(out, "bad src reg %s\n", name);
614 sprintf(name, "T%d", src_nr);
615 else if (src_nr == 8)
616 sprintf(name, "DIFFUSE");
617 else if (src_nr == 9)
618 sprintf(name, "SPECULAR");
619 else if (src_nr == 10)
620 sprintf(name, "FOG");
622 fprintf(out, "bad src reg T%d\n", src_nr);
623 sprintf(name, "RESERVED");
627 sprintf(name, "C%d", src_nr);
629 fprintf(out, "bad src reg %s\n", name);
634 fprintf(out, "bad src reg oC%d\n", src_nr);
639 fprintf(out, "bad src reg oD%d\n", src_nr);
642 sprintf(name, "U%d", src_nr);
644 fprintf(out, "bad src reg %s\n", name);
647 fprintf(out, "bad src reg type %d\n", src_type);
648 sprintf(name, "RESERVED");
653 static void i915_get_instruction_src0(uint32_t *data, int i, char *srcname)
655 uint32_t a0 = data[i];
656 uint32_t a1 = data[i + 1];
657 int src_nr = (a0 >> 2) & 0x1f;
658 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
659 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
660 const char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
661 const char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
664 i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
665 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
667 if (strcmp(swizzle, ".xyzw") != 0)
668 strcat(srcname, swizzle);
671 static void i915_get_instruction_src1(uint32_t *data, int i, char *srcname)
673 uint32_t a1 = data[i + 1];
674 uint32_t a2 = data[i + 2];
675 int src_nr = (a1 >> 8) & 0x1f;
676 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
677 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
678 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
679 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
682 i915_get_instruction_src_name((a1 >> 13) & 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_src2(uint32_t *data, int i, char *srcname)
691 uint32_t a2 = data[i + 2];
692 int src_nr = (a2 >> 16) & 0x1f;
693 const char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
694 const char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
695 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
696 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
699 i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
700 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
702 if (strcmp(swizzle, ".xyzw") != 0)
703 strcat(srcname, swizzle);
707 i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
711 sprintf(name, "R%d", src_nr);
713 fprintf(out, "bad src reg %s\n", name);
717 sprintf(name, "T%d", src_nr);
718 else if (src_nr == 8)
719 sprintf(name, "DIFFUSE");
720 else if (src_nr == 9)
721 sprintf(name, "SPECULAR");
722 else if (src_nr == 10)
723 sprintf(name, "FOG");
725 fprintf(out, "bad src reg T%d\n", src_nr);
726 sprintf(name, "RESERVED");
732 fprintf(out, "bad src reg oC%d\n", src_nr);
737 fprintf(out, "bad src reg oD%d\n", src_nr);
740 fprintf(out, "bad src reg type %d\n", src_type);
741 sprintf(name, "RESERVED");
747 i915_decode_alu1(uint32_t *data, uint32_t hw_offset,
748 int i, char *instr_prefix, const char *op_name)
750 char dst[100], src0[100];
752 i915_get_instruction_dst(data, i, dst, 1);
753 i915_get_instruction_src0(data, i, src0);
755 instr_out(data, hw_offset, i++, "%s: %s %s, %s\n", instr_prefix,
757 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
758 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
762 i915_decode_alu2(uint32_t *data, uint32_t hw_offset,
763 int i, char *instr_prefix, const char *op_name)
765 char dst[100], src0[100], src1[100];
767 i915_get_instruction_dst(data, i, dst, 1);
768 i915_get_instruction_src0(data, i, src0);
769 i915_get_instruction_src1(data, i, src1);
771 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s\n", instr_prefix,
772 op_name, dst, src0, src1);
773 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
774 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
778 i915_decode_alu3(uint32_t *data, uint32_t hw_offset,
779 int i, char *instr_prefix, const char *op_name)
781 char dst[100], src0[100], src1[100], src2[100];
783 i915_get_instruction_dst(data, i, dst, 1);
784 i915_get_instruction_src0(data, i, src0);
785 i915_get_instruction_src1(data, i, src1);
786 i915_get_instruction_src2(data, i, src2);
788 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
789 op_name, dst, src0, src1, src2);
790 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
791 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
795 i915_decode_tex(uint32_t *data, uint32_t hw_offset, int i,
796 const char *instr_prefix, const char *tex_name)
798 uint32_t t0 = data[i];
799 uint32_t t1 = data[i + 1];
804 i915_get_instruction_dst(data, i, dst_name, 0);
805 i915_get_instruction_addr((t1 >> 24) & 0x7,
806 (t1 >> 17) & 0xf, addr_name);
807 sampler_nr = t0 & 0xf;
809 instr_out(data, hw_offset, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
810 tex_name, dst_name, sampler_nr, addr_name);
811 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
812 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
816 i915_decode_dcl(uint32_t *data, uint32_t hw_offset, int i, char *instr_prefix)
818 uint32_t d0 = data[i];
819 const char *sampletype;
820 int dcl_nr = (d0 >> 14) & 0xf;
821 const char *dcl_x = d0 & (1 << 10) ? "x" : "";
822 const char *dcl_y = d0 & (1 << 11) ? "y" : "";
823 const char *dcl_z = d0 & (1 << 12) ? "z" : "";
824 const char *dcl_w = d0 & (1 << 13) ? "w" : "";
827 switch ((d0 >> 19) & 0x3) {
829 sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
830 if (strcmp(dcl_mask, ".") == 0)
831 fprintf(out, "bad (empty) dcl mask\n");
834 fprintf(out, "bad T%d dcl register number\n", dcl_nr);
836 if (strcmp(dcl_mask, ".x") != 0 &&
837 strcmp(dcl_mask, ".xy") != 0 &&
838 strcmp(dcl_mask, ".xz") != 0 &&
839 strcmp(dcl_mask, ".w") != 0 &&
840 strcmp(dcl_mask, ".xyzw") != 0) {
841 fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr,
844 instr_out(data, hw_offset, i++, "%s: DCL T%d%s\n",
845 instr_prefix, dcl_nr, dcl_mask);
847 if (strcmp(dcl_mask, ".xz") == 0)
848 fprintf(out, "errataed bad dcl mask %s\n",
850 else if (strcmp(dcl_mask, ".xw") == 0)
851 fprintf(out, "errataed bad dcl mask %s\n",
853 else if (strcmp(dcl_mask, ".xzw") == 0)
854 fprintf(out, "errataed bad dcl mask %s\n",
858 instr_out(data, hw_offset, i++,
859 "%s: DCL DIFFUSE%s\n", instr_prefix,
861 } else if (dcl_nr == 9) {
862 instr_out(data, hw_offset, i++,
863 "%s: DCL SPECULAR%s\n", instr_prefix,
865 } else if (dcl_nr == 10) {
866 instr_out(data, hw_offset, i++,
867 "%s: DCL FOG%s\n", instr_prefix,
871 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
872 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
875 switch ((d0 >> 22) & 0x3) {
886 sampletype = "RESERVED";
890 fprintf(out, "bad S%d dcl register number\n", dcl_nr);
891 instr_out(data, hw_offset, i++, "%s: DCL S%d %s\n",
892 instr_prefix, dcl_nr, sampletype);
893 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
894 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
897 instr_out(data, hw_offset, i++, "%s: DCL RESERVED%d\n",
898 instr_prefix, dcl_nr);
899 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
900 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
905 i915_decode_instruction(uint32_t *data, uint32_t hw_offset,
906 int i, char *instr_prefix)
908 switch ((data[i] >> 24) & 0x1f) {
910 instr_out(data, hw_offset, i++, "%s: NOP\n", instr_prefix);
911 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
912 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
915 i915_decode_alu2(data, hw_offset, i, instr_prefix, "ADD");
918 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOV");
921 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MUL");
924 i915_decode_alu3(data, hw_offset, i, instr_prefix, "MAD");
927 i915_decode_alu3(data, hw_offset, i, instr_prefix, "DP2ADD");
930 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP3");
933 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP4");
936 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FRC");
939 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RCP");
942 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RSQ");
945 i915_decode_alu1(data, hw_offset, i, instr_prefix, "EXP");
948 i915_decode_alu1(data, hw_offset, i, instr_prefix, "LOG");
951 i915_decode_alu2(data, hw_offset, i, instr_prefix, "CMP");
954 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MIN");
957 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MAX");
960 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FLR");
963 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOD");
966 i915_decode_alu1(data, hw_offset, i, instr_prefix, "TRC");
969 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SGE");
972 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SLT");
975 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLD");
978 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDP");
981 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDB");
984 i915_decode_dcl(data, hw_offset, i, instr_prefix);
987 instr_out(data, hw_offset, i++, "%s: unknown\n", instr_prefix);
988 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
989 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
995 decode_compare_func(uint32_t op)
1019 decode_stencil_op(uint32_t op)
1043 decode_logic_op(uint32_t op)
1083 decode_blend_fact(uint32_t op)
1093 return "inv_src_colr";
1097 return "inv_src_alpha";
1101 return "inv_dst_alpha";
1105 return "inv_dst_colr";
1107 return "src_alpha_sat";
1111 return "inv_cnst_colr";
1113 return "cnst_alpha";
1115 return "inv_const_alpha";
1121 decode_tex_coord_mode(uint32_t mode)
1123 switch (mode & 0x7) {
1129 return "clamp_edge";
1133 return "clamp_border";
1135 return "mirror_once";
1141 decode_sample_filter(uint32_t mode)
1143 switch (mode & 0x7) {
1149 return "anisotropic";
1163 decode_3d_1d(uint32_t *data, uint32_t count,
1164 uint32_t hw_offset, uint32_t devid, int *failures)
1166 unsigned int len, i, c, idx, word, map, sampler, instr;
1167 const char *format, *zformat, *type;
1173 unsigned int min_len;
1174 unsigned int max_len;
1176 } opcodes_3d_1d[] = {
1177 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
1178 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
1179 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
1180 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
1181 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
1182 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
1183 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
1184 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
1185 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
1186 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
1187 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
1188 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
1189 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
1190 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
1191 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
1192 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830"},
1195 opcode = (data[0] & 0x00ff0000) >> 16;
1199 /* This instruction is unusual. A 0 length means just
1200 * 1 DWORD instead of 2. The 0 length is specified in
1201 * one place to be unsupported, but stated to be
1202 * required in another, and 0 length LOAD_INDIRECTs
1203 * appear to cause no harm at least.
1205 instr_out(data, hw_offset, 0, "3DSTATE_LOAD_INDIRECT\n");
1206 len = (data[0] & 0x000000ff) + 1;
1208 if (data[0] & (0x01 << 8)) {
1210 BUFFER_FAIL(count, len,
1211 "3DSTATE_LOAD_INDIRECT");
1212 instr_out(data, hw_offset, i++, "SIS.0\n");
1213 instr_out(data, hw_offset, i++, "SIS.1\n");
1215 if (data[0] & (0x02 << 8)) {
1217 BUFFER_FAIL(count, len,
1218 "3DSTATE_LOAD_INDIRECT");
1219 instr_out(data, hw_offset, i++, "DIS.0\n");
1221 if (data[0] & (0x04 << 8)) {
1223 BUFFER_FAIL(count, len,
1224 "3DSTATE_LOAD_INDIRECT");
1225 instr_out(data, hw_offset, i++, "SSB.0\n");
1226 instr_out(data, hw_offset, i++, "SSB.1\n");
1228 if (data[0] & (0x08 << 8)) {
1230 BUFFER_FAIL(count, len,
1231 "3DSTATE_LOAD_INDIRECT");
1232 instr_out(data, hw_offset, i++, "MSB.0\n");
1233 instr_out(data, hw_offset, i++, "MSB.1\n");
1235 if (data[0] & (0x10 << 8)) {
1237 BUFFER_FAIL(count, len,
1238 "3DSTATE_LOAD_INDIRECT");
1239 instr_out(data, hw_offset, i++, "PSP.0\n");
1240 instr_out(data, hw_offset, i++, "PSP.1\n");
1242 if (data[0] & (0x20 << 8)) {
1244 BUFFER_FAIL(count, len,
1245 "3DSTATE_LOAD_INDIRECT");
1246 instr_out(data, hw_offset, i++, "PSC.0\n");
1247 instr_out(data, hw_offset, i++, "PSC.1\n");
1250 fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
1256 instr_out(data, hw_offset, 0,
1257 "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1258 len = (data[0] & 0x0000000f) + 2;
1260 for (word = 0; word <= 8; word++) {
1261 if (data[0] & (1 << (4 + word))) {
1263 BUFFER_FAIL(count, len,
1264 "3DSTATE_LOAD_STATE_IMMEDIATE_1");
1266 /* save vertex state for decode */
1267 if (!IS_GEN2(devid)) {
1279 instr_out(data, hw_offset, i,
1280 "S0: vbo offset: 0x%08x%s\n",
1283 ", auto cache invalidate disabled"
1287 instr_out(data, hw_offset, i,
1288 "S1: vertex width: %i, vertex pitch: %i\n",
1295 instr_out(data, hw_offset, i,
1296 "S2: texcoord formats: ");
1297 for (int tex_num = 0;
1298 tex_num < 8; tex_num++) {
1343 instr_out(data, hw_offset, i,
1344 "S3: not documented\n",
1349 const char *cullmode = "";
1350 const char *vfmt_xyzw = "";
1351 switch ((data[i] >> 13)
1388 case 1 << 6 | 1 << 2:
1392 case 2 << 6 | 1 << 2:
1396 case 3 << 6 | 1 << 2:
1400 case 4 << 6 | 1 << 2:
1407 "S4: point_width=%i, line_width=%.1f,"
1408 "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s "
1471 "force default diffuse, "
1477 "force default specular, "
1483 "local depth ofs enable, "
1489 "point sprite enable, "
1504 "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, "
1505 "stencil_fail=%s, stencil_pass_z_fail=%s, "
1506 "stencil_pass_z_pass=%s, %s%s%s%s\n",
1536 " force default point size,"
1542 " last pixel enable,"
1548 " global depth ofs enable,"
1574 "stencil write enable, "
1580 "stencil test enable, "
1586 "color dither enable, "
1597 instr_out(data, hw_offset, i,
1598 "S6: %salpha_test=%s, alpha_ref=0x%x, "
1599 "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, "
1600 "%s%stristrip_provoking_vertex=%i\n",
1601 data[i] & (1 << 31) ?
1602 "alpha test enable, "
1610 data[i] & (1 << 15) ?
1611 "cbuf blend enable, "
1613 decode_blend_fact(data
1617 decode_blend_fact(data
1621 data[i] & (1 << 3) ?
1622 "depth write enable, "
1624 data[i] & (1 << 2) ?
1625 "cbuf write enable, "
1630 instr_out(data, hw_offset, i,
1631 "S7: depth offset constant: 0x%08x\n",
1636 instr_out(data, hw_offset, i,
1637 "S%d: 0x%08x\n", i, data[i]);
1644 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1649 instr_out(data, hw_offset, 0,
1650 "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1651 len = (data[0] & 0x0000000f) + 2;
1653 for (word = 6; word <= 14; word++) {
1654 if (data[0] & (1 << word)) {
1656 BUFFER_FAIL(count, len,
1657 "3DSTATE_LOAD_STATE_IMMEDIATE_2");
1660 instr_out(data, hw_offset, i++,
1662 else if (word >= 7 && word <= 10) {
1663 instr_out(data, hw_offset, i++,
1664 "TB%dC\n", word - 7);
1665 instr_out(data, hw_offset, i++,
1666 "TB%dA\n", word - 7);
1667 } else if (word >= 11 && word <= 14) {
1668 instr_out(data, hw_offset, i,
1669 "TM%dS0: offset=0x%08x, %s\n",
1671 data[i] & 0xfffffffe,
1672 data[i] & 1 ? "use fence" :
1675 instr_out(data, hw_offset, i,
1676 "TM%dS1: height=%i, width=%i, %s\n",
1677 word - 11, data[i] >> 21,
1678 (data[i] >> 10) & 0x3ff,
1679 data[i] & 2 ? (data[i] & 1 ?
1684 instr_out(data, hw_offset, i,
1685 "TM%dS2: pitch=%i, \n",
1687 ((data[i] >> 21) + 1) * 4);
1689 instr_out(data, hw_offset, i++,
1690 "TM%dS3\n", word - 11);
1691 instr_out(data, hw_offset, i++,
1692 "TM%dS4: dflt color\n",
1699 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1704 instr_out(data, hw_offset, 0, "3DSTATE_MAP_STATE\n");
1705 len = (data[0] & 0x0000003f) + 2;
1706 instr_out(data, hw_offset, 1, "mask\n");
1709 for (map = 0; map <= 15; map++) {
1710 if (data[1] & (1 << map)) {
1711 int width, height, pitch, dword;
1715 BUFFER_FAIL(count, len,
1716 "3DSTATE_MAP_STATE");
1719 instr_out(data, hw_offset, i++,
1720 "map %d MS2 %s%s%s\n", map,
1722 "untrusted surface, " : "",
1724 "vertical line stride enable, " : "",
1726 "vertical ofs enable, " : "");
1729 width = ((dword >> 10) & ((1 << 11) - 1)) + 1;
1730 height = ((dword >> 21) & ((1 << 11) - 1)) + 1;
1733 if (dword & (1 << 2))
1735 else if (dword & (1 << 1))
1736 tiling = dword & (1 << 0) ? "Y" : "X";
1739 switch ((dword >> 7) & 0x7) {
1742 switch ((dword >> 3) & 0xf) {
1759 switch ((dword >> 3) & 0xf) {
1764 format = " argb1555";
1767 format = " argb4444";
1773 format = " bump655";
1788 switch ((dword >> 3) & 0xf) {
1790 format = " argb8888";
1793 format = " abgr8888";
1796 format = " xrgb8888";
1799 format = " xbgr8888";
1802 format = " qwvu8888";
1805 format = " axvu8888";
1808 format = " lxvu8888";
1811 format = " xlvu8888";
1814 format = " argb2101010";
1817 format = " abgr2101010";
1820 format = " awvu2101010";
1841 switch ((dword >> 3) & 0xf) {
1843 format = " yuv_swapy";
1849 format = " yuv_swapuv";
1852 format = " yuv_swapuvy";
1857 type = "compressed";
1858 switch ((dword >> 3) & 0x7) {
1872 format = " dxt1_rb";
1877 type = "4b indexed";
1878 switch ((dword >> 3) & 0xf) {
1880 format = " argb8888";
1886 instr_out(data, hw_offset, i++,
1887 "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n",
1888 map, width, height, type, format,
1890 dword & (1 << 9) ? " palette select" :
1895 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1);
1896 instr_out(data, hw_offset, i++,
1897 "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n",
1898 map, pitch, (dword >> 9) & 0x3f,
1899 dword & 0xff, (dword >> 15) & 0x3f,
1900 dword & (1 << 8) ? "miplayout legacy"
1901 : "miplayout right");
1905 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
1911 instr_out(data, hw_offset, 0,
1912 "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1913 len = (data[0] & 0x000000ff) + 2;
1916 for (c = 0; c <= 31; c++) {
1917 if (data[1] & (1 << c)) {
1919 BUFFER_FAIL(count, len,
1920 "3DSTATE_PIXEL_SHADER_CONSTANTS");
1921 instr_out(data, hw_offset, i, "C%d.X = %f\n", c,
1922 int_as_float(data[i]));
1924 instr_out(data, hw_offset, i, "C%d.Y = %f\n",
1925 c, int_as_float(data[i]));
1927 instr_out(data, hw_offset, i, "C%d.Z = %f\n",
1928 c, int_as_float(data[i]));
1930 instr_out(data, hw_offset, i, "C%d.W = %f\n",
1931 c, int_as_float(data[i]));
1937 "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1942 instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
1943 len = (data[0] & 0x000000ff) + 2;
1944 if ((len - 1) % 3 != 0 || len > 370) {
1946 "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
1950 for (instr = 0; instr < (len - 1) / 3; instr++) {
1951 char instr_prefix[10];
1954 BUFFER_FAIL(count, len,
1955 "3DSTATE_PIXEL_SHADER_PROGRAM");
1956 sprintf(instr_prefix, "PS%03d", instr);
1957 i915_decode_instruction(data, hw_offset, i,
1965 instr_out(data, hw_offset, 0, "3DSTATE_SAMPLER_STATE\n");
1966 instr_out(data, hw_offset, 1, "mask\n");
1967 len = (data[0] & 0x0000003f) + 2;
1969 for (sampler = 0; sampler <= 15; sampler++) {
1970 if (data[1] & (1 << sampler)) {
1972 const char *mip_filter = "";
1974 BUFFER_FAIL(count, len,
1975 "3DSTATE_SAMPLER_STATE");
1977 switch ((dword >> 20) & 0x3) {
1979 mip_filter = "none";
1982 mip_filter = "nearest";
1985 mip_filter = "linear";
1988 instr_out(data, hw_offset, i++,
1989 "sampler %d SS2:%s%s%s "
1990 "base_mip_level=%i, mip_filter=%s, mag_filter=%s, min_filter=%s "
1991 "lod_bias=%.2f,%s max_aniso=%i, shadow_func=%s\n",
1993 dword & (1 << 31) ? " reverse gamma,"
1995 dword & (1 << 30) ? " packed2planar,"
1998 " colorspace conversion," : "",
1999 (dword >> 22) & 0x1f, mip_filter,
2000 decode_sample_filter(dword >> 17),
2001 decode_sample_filter(dword >> 14),
2002 ((dword >> 5) & 0x1ff) / (0x10 * 1.0),
2003 dword & (1 << 4) ? " shadow," : "",
2004 dword & (1 << 3) ? 4 : 2,
2005 decode_compare_func(dword));
2007 instr_out(data, hw_offset, i++,
2008 "sampler %d SS3: min_lod=%.2f,%s "
2009 "tcmode_x=%s, tcmode_y=%s, tcmode_z=%s,%s texmap_idx=%i,%s\n",
2011 ((dword >> 24) & 0xff) / (0x10 * 1.0),
2013 " kill pixel enable," : "",
2014 decode_tex_coord_mode(dword >> 12),
2015 decode_tex_coord_mode(dword >> 9),
2016 decode_tex_coord_mode(dword >> 6),
2018 " normalized coords," : "",
2020 dword & (1 << 0) ? " deinterlacer," :
2023 instr_out(data, hw_offset, i++,
2024 "sampler %d SS4: border color\n",
2026 ((dword >> 24) & 0xff) / (0x10 * 1.0),
2031 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
2036 len = (data[0] & 0x0000000f) + 2;
2040 "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
2042 BUFFER_FAIL(count, len,
2043 "3DSTATE_DEST_BUFFER_VARIABLES");
2045 instr_out(data, hw_offset, 0,
2046 "3DSTATE_DEST_BUFFER_VARIABLES\n");
2048 switch ((data[1] >> 8) & 0xf) {
2053 format = "x1r5g5b5";
2059 format = "a8r8g8b8";
2062 format = "ycrcb_swapy";
2065 format = "ycrcb_normal";
2068 format = "ycrcb_swapuv";
2071 format = "ycrcb_swapuvy";
2074 format = "a4r4g4b4";
2077 format = "a1r5g5b5";
2080 format = "a2r10g10b10";
2086 switch ((data[1] >> 2) & 0x3) {
2100 instr_out(data, hw_offset, 1,
2101 "%s format, %s depth format, early Z %sabled\n",
2103 (data[1] & (1 << 31)) ? "en" : "dis");
2108 const char *name, *tiling;
2110 len = (data[0] & 0x0000000f) + 2;
2113 "Bad count in 3DSTATE_BUFFER_INFO\n");
2115 BUFFER_FAIL(count, len, "3DSTATE_BUFFER_INFO");
2117 switch ((data[1] >> 24) & 0x7) {
2130 if (data[1] & (1 << 23))
2132 else if (data[1] & (1 << 22))
2133 tiling = data[1] & (1 << 21) ? "Y" : "X";
2135 instr_out(data, hw_offset, 0, "3DSTATE_BUFFER_INFO\n");
2136 instr_out(data, hw_offset, 1,
2137 "%s, tiling = %s, pitch=%d\n", name, tiling,
2140 instr_out(data, hw_offset, 2, "address\n");
2144 len = (data[0] & 0x0000000f) + 2;
2148 "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n");
2150 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_RECTANGLE");
2152 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_RECTANGLE\n");
2153 instr_out(data, hw_offset, 1, "(%d,%d)\n",
2154 data[1] & 0xffff, data[1] >> 16);
2155 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2156 data[2] & 0xffff, data[2] >> 16);
2160 len = (data[0] & 0x0000000f) + 2;
2164 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2166 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
2168 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
2169 instr_out(data, hw_offset, 1, "%s\n",
2170 data[1] & (1 << 30) ? "depth ofs disabled " : "");
2171 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2172 data[2] & 0xffff, data[2] >> 16);
2173 instr_out(data, hw_offset, 3, "(%d,%d)\n",
2174 data[3] & 0xffff, data[3] >> 16);
2175 instr_out(data, hw_offset, 4, "(%d,%d)\n",
2176 data[4] & 0xffff, data[4] >> 16);
2180 len = (data[0] & 0x0000000f) + 2;
2183 fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n");
2185 BUFFER_FAIL(count, len, "3DSTATE_CLEAR_PARAMETERS");
2187 instr_out(data, hw_offset, 0, "3DSTATE_CLEAR_PARAMETERS\n");
2188 instr_out(data, hw_offset, 1, "prim_type=%s, clear=%s%s%s\n",
2189 data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT",
2190 data[1] & (1 << 2) ? "color," : "",
2191 data[1] & (1 << 1) ? "depth," : "",
2192 data[1] & (1 << 0) ? "stencil," : "");
2193 instr_out(data, hw_offset, 2, "clear color\n");
2194 instr_out(data, hw_offset, 3, "clear depth/stencil\n");
2195 instr_out(data, hw_offset, 4, "color value (rgba8888)\n");
2196 instr_out(data, hw_offset, 5, "depth value %f\n",
2197 int_as_float(data[5]));
2198 instr_out(data, hw_offset, 6, "clear stencil\n");
2202 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) {
2203 opcode_3d_1d = &opcodes_3d_1d[idx];
2204 if (opcode_3d_1d->i830_only && !IS_GEN2(devid))
2207 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
2210 instr_out(data, hw_offset, 0, "%s\n",
2211 opcode_3d_1d->name);
2212 if (opcode_3d_1d->max_len > 1) {
2213 len = (data[0] & 0x0000ffff) + 2;
2214 if (len < opcode_3d_1d->min_len ||
2215 len > opcode_3d_1d->max_len) {
2216 fprintf(out, "Bad count in %s\n",
2217 opcode_3d_1d->name);
2222 for (i = 1; i < len; i++) {
2224 BUFFER_FAIL(count, len,
2225 opcode_3d_1d->name);
2226 instr_out(data, hw_offset, i, "dword %d\n", i);
2233 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n",
2240 decode_3d_primitive(uint32_t *data, uint32_t count, uint32_t hw_offset,
2243 char immediate = (data[0] & (1 << 23)) == 0;
2244 unsigned int len, i, j, ret;
2245 const char *primtype;
2246 int original_s2 = saved_s2;
2247 int original_s4 = saved_s4;
2249 switch ((data[0] >> 18) & 0xf) {
2251 primtype = "TRILIST";
2254 primtype = "TRISTRIP";
2257 primtype = "TRISTRIP_REVERSE";
2260 primtype = "TRIFAN";
2263 primtype = "POLYGON";
2266 primtype = "LINELIST";
2269 primtype = "LINESTRIP";
2272 primtype = "RECTLIST";
2275 primtype = "POINTLIST";
2281 primtype = "CLEAR_RECT";
2286 primtype = "unknown";
2290 /* XXX: 3DPRIM_DIB not supported */
2292 len = (data[0] & 0x0003ffff) + 2;
2293 instr_out(data, hw_offset, 0, "3DPRIMITIVE inline %s\n",
2296 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
2297 if (!saved_s2_set || !saved_s4_set) {
2298 fprintf(out, "unknown vertex format\n");
2299 for (i = 1; i < len; i++) {
2300 instr_out(data, hw_offset, i,
2301 " vertex data (%f float)\n",
2302 int_as_float(data[i]));
2305 unsigned int vertex = 0;
2306 for (i = 1; i < len;) {
2309 #define VERTEX_OUT(fmt, ...) do { \
2311 instr_out(data, hw_offset, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
2313 fprintf(out, " missing data in V%d\n", vertex); \
2317 VERTEX_OUT("X = %f", int_as_float(data[i]));
2318 VERTEX_OUT("Y = %f", int_as_float(data[i]));
2319 switch (saved_s4 >> 6 & 0x7) {
2321 VERTEX_OUT("Z = %f",
2322 int_as_float(data[i]));
2325 VERTEX_OUT("Z = %f",
2326 int_as_float(data[i]));
2327 VERTEX_OUT("W = %f",
2328 int_as_float(data[i]));
2333 VERTEX_OUT("W = %f",
2334 int_as_float(data[i]));
2337 fprintf(out, "bad S4 position mask\n");
2340 if (saved_s4 & (1 << 10)) {
2342 ("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
2343 "B=0x%02x)", data[i] >> 24,
2344 (data[i] >> 16) & 0xff,
2345 (data[i] >> 8) & 0xff,
2348 if (saved_s4 & (1 << 11)) {
2350 ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
2351 "B=0x%02x)", data[i] >> 24,
2352 (data[i] >> 16) & 0xff,
2353 (data[i] >> 8) & 0xff,
2356 if (saved_s4 & (1 << 12))
2357 VERTEX_OUT("width = 0x%08x)", data[i]);
2359 for (tc = 0; tc <= 7; tc++) {
2360 switch ((saved_s2 >> (tc * 4)) & 0xf) {
2362 VERTEX_OUT("T%d.X = %f", tc,
2365 VERTEX_OUT("T%d.Y = %f", tc,
2370 VERTEX_OUT("T%d.X = %f", tc,
2373 VERTEX_OUT("T%d.Y = %f", tc,
2376 VERTEX_OUT("T%d.Z = %f", tc,
2381 VERTEX_OUT("T%d.X = %f", tc,
2384 VERTEX_OUT("T%d.Y = %f", tc,
2387 VERTEX_OUT("T%d.Z = %f", tc,
2390 VERTEX_OUT("T%d.W = %f", tc,
2395 VERTEX_OUT("T%d.X = %f", tc,
2401 ("T%d.XY = 0x%08x half-float",
2406 ("T%d.XY = 0x%08x half-float",
2409 ("T%d.ZW = 0x%08x half-float",
2416 "bad S2.T%d format\n",
2426 /* indirect vertices */
2427 len = data[0] & 0x0000ffff; /* index count */
2428 if (data[0] & (1 << 17)) {
2429 /* random vertex access */
2430 if (count < (len + 1) / 2 + 1) {
2431 BUFFER_FAIL(count, (len + 1) / 2 + 1,
2432 "3DPRIMITIVE random indirect");
2434 instr_out(data, hw_offset, 0,
2435 "3DPRIMITIVE random indirect %s (%d)\n",
2438 /* vertex indices continue until 0xffff is
2441 for (i = 1; i < count; i++) {
2442 if ((data[i] & 0xffff) == 0xffff) {
2443 instr_out(data, hw_offset, i,
2444 " indices: (terminator)\n");
2447 } else if ((data[i] >> 16) == 0xffff) {
2448 instr_out(data, hw_offset, i,
2449 " indices: 0x%04x, (terminator)\n",
2454 instr_out(data, hw_offset, i,
2455 " indices: 0x%04x, 0x%04x\n",
2461 "3DPRIMITIVE: no terminator found in index buffer\n");
2466 /* fixed size vertex index buffer */
2467 for (j = 1, i = 0; i < len; i += 2, j++) {
2468 if (i * 2 == len - 1) {
2469 instr_out(data, hw_offset, j,
2470 " indices: 0x%04x\n",
2473 instr_out(data, hw_offset, j,
2474 " indices: 0x%04x, 0x%04x\n",
2480 ret = (len + 1) / 2 + 1;
2483 /* sequential vertex access */
2485 BUFFER_FAIL(count, 2,
2486 "3DPRIMITIVE seq indirect");
2487 instr_out(data, hw_offset, 0,
2488 "3DPRIMITIVE sequential indirect %s, %d starting from "
2489 "%d\n", primtype, len, data[1] & 0xffff);
2490 instr_out(data, hw_offset, 1, " start\n");
2497 saved_s2 = original_s2;
2498 saved_s4 = original_s4;
2503 decode_3d(uint32_t *data, uint32_t count, uint32_t hw_offset, uint32_t devid,
2511 unsigned int min_len;
2512 unsigned int max_len;
2515 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
2516 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
2517 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
2518 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
2519 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
2520 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
2521 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
2522 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
2523 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES"},
2526 opcode = (data[0] & 0x1f000000) >> 24;
2530 return decode_3d_primitive(data, count, hw_offset, failures);
2532 return decode_3d_1d(data, count, hw_offset, devid, failures);
2534 return decode_3d_1c(data, count, hw_offset, failures);
2537 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2538 opcode_3d = &opcodes_3d[idx];
2539 if (opcode == opcode_3d->opcode) {
2540 unsigned int len = 1, i;
2542 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
2543 if (opcode_3d->max_len > 1) {
2544 len = (data[0] & 0xff) + 2;
2545 if (len < opcode_3d->min_len ||
2546 len > opcode_3d->max_len) {
2547 fprintf(out, "Bad count in %s\n",
2552 for (i = 1; i < len; i++) {
2554 BUFFER_FAIL(count, len,
2556 instr_out(data, hw_offset, i, "dword %d\n", i);
2562 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode);
2567 static const char *get_965_surfacetype(unsigned int surfacetype)
2569 switch (surfacetype) {
2587 static const char *get_965_depthformat(unsigned int depthformat)
2589 switch (depthformat) {
2591 return "s8_z24float";
2603 static const char *get_965_element_component(uint32_t data, int component)
2605 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
2607 switch (component_control) {
2611 switch (component) {
2636 static const char *get_965_prim_type(uint32_t data)
2638 uint32_t primtype = (data >> 10) & 0x1f;
2642 return "point list";
2646 return "line strip";
2656 return "quad strip";
2658 return "line list adj";
2660 return "line strip adj";
2662 return "tri list adj";
2664 return "tri strip adj";
2666 return "tri strip reverse";
2674 return "point list bf";
2676 return "line strip cont";
2678 return "line strip bf";
2680 return "line strip cont bf";
2682 return "tri fan no stipple";
2689 i965_decode_urb_fence(uint32_t *data, uint32_t hw_offset, int len, uint32_t count,
2692 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
2695 fprintf(out, "Bad count in URB_FENCE\n");
2697 BUFFER_FAIL(count, len, "URB_FENCE");
2699 vs_fence = data[1] & 0x3ff;
2700 gs_fence = (data[1] >> 10) & 0x3ff;
2701 clip_fence = (data[1] >> 20) & 0x3ff;
2702 sf_fence = data[2] & 0x3ff;
2703 vfe_fence = (data[2] >> 10) & 0x3ff;
2704 cs_fence = (data[2] >> 20) & 0x7ff;
2706 instr_out(data, hw_offset, 0, "URB_FENCE: %s%s%s%s%s%s\n",
2707 (data[0] >> 13) & 1 ? "cs " : "",
2708 (data[0] >> 12) & 1 ? "vfe " : "",
2709 (data[0] >> 11) & 1 ? "sf " : "",
2710 (data[0] >> 10) & 1 ? "clip " : "",
2711 (data[0] >> 9) & 1 ? "gs " : "",
2712 (data[0] >> 8) & 1 ? "vs " : "");
2713 instr_out(data, hw_offset, 1,
2714 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
2715 vs_fence, clip_fence, gs_fence);
2716 instr_out(data, hw_offset, 2,
2717 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
2718 sf_fence, vfe_fence, cs_fence);
2719 if (gs_fence < vs_fence)
2720 fprintf(out, "gs fence < vs fence!\n");
2721 if (clip_fence < gs_fence)
2722 fprintf(out, "clip fence < gs fence!\n");
2723 if (sf_fence < clip_fence)
2724 fprintf(out, "sf fence < clip fence!\n");
2725 if (cs_fence < sf_fence)
2726 fprintf(out, "cs fence < sf fence!\n");
2732 state_base_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2735 if (data[index] & 1) {
2736 instr_out(data, hw_offset, index,
2737 "%s state base address 0x%08x\n", name,
2740 instr_out(data, hw_offset, index, "%s state base not updated\n",
2746 state_max_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2749 if (data[index] & 1) {
2750 if (data[index] == 1) {
2751 instr_out(data, hw_offset, index,
2752 "%s state upper bound disabled\n", name);
2754 instr_out(data, hw_offset, index,
2755 "%s state upper bound 0x%08x\n", name,
2759 instr_out(data, hw_offset, index,
2760 "%s state upper bound not updated\n", name);
2765 decode_3d_965(uint32_t *data, uint32_t count, uint32_t hw_offset, uint32_t devid,
2769 unsigned int idx, len;
2770 unsigned int i, sba_len;
2771 const char *desc1 = NULL;
2775 int unsigned min_len;
2776 int unsigned max_len;
2779 { 0x6000, 3, 3, "URB_FENCE" },
2780 { 0x6001, 2, 2, "CS_URB_STATE" },
2781 { 0x6002, 2, 2, "CONSTANT_BUFFER" },
2782 { 0x6101, 6, 6, "STATE_BASE_ADDRESS" },
2783 { 0x6102, 2, 2, "STATE_SIP" },
2784 { 0x6104, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2785 { 0x680b, 1, 1, "3DSTATE_VF_STATISTICS" },
2786 { 0x6904, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2787 { 0x7800, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
2788 { 0x7801, 6, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
2789 { 0x7808, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
2790 { 0x7809, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
2791 { 0x780a, 3, 3, "3DSTATE_INDEX_BUFFER" },
2792 { 0x780b, 1, 1, "3DSTATE_VF_STATISTICS" },
2793 { 0x7900, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
2794 { 0x7901, 5, 5, "3DSTATE_CONSTANT_COLOR" },
2795 { 0x7905, 5, 7, "3DSTATE_DEPTH_BUFFER" },
2796 { 0x7906, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
2797 { 0x7907, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
2798 { 0x7908, 3, 3, "3DSTATE_LINE_STIPPLE" },
2799 { 0x7909, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
2800 { 0x7909, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2801 { 0x790a, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
2802 { 0x790b, 4, 4, "3DSTATE_GS_SVB_INDEX" },
2803 { 0x790d, 3, 3, "3DSTATE_MULTISAMPLE" },
2804 { 0x7910, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2805 { 0x7b00, 6, 6, "3DPRIMITIVE" },
2806 { 0x7802, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
2807 { 0x7805, 3, 3, "3DSTATE_URB" },
2808 { 0x780d, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
2809 { 0x780e, 4, 4, "3DSTATE_CC_STATE_POINTERS" },
2810 { 0x780f, 2, 2, "3DSTATE_SCISSOR_STATE_POINTERS" },
2811 { 0x7810, 6, 6, "3DSTATE_VS_STATE" },
2812 { 0x7811, 7, 7, "3DSTATE_GS_STATE" },
2813 { 0x7812, 4, 4, "3DSTATE_CLIP_STATE" },
2814 { 0x7813, 20, 20, "3DSTATE_SF_STATE" },
2815 { 0x7814, 9, 9, "3DSTATE_WM_STATE" },
2816 { 0x7815, 5, 5, "3DSTATE_CONSTANT_VS_STATE" },
2817 { 0x7816, 5, 5, "3DSTATE_CONSTANT_GS_STATE" },
2818 { 0x7817, 5, 5, "3DSTATE_CONSTANT_PS_STATE" },
2819 { 0x7818, 2, 2, "3DSTATE_SAMPLE_MASK"},
2822 len = (data[0] & 0x0000ffff) + 2;
2824 opcode = (data[0] & 0xffff0000) >> 16;
2827 len = (data[0] & 0x000000ff) + 2;
2828 return i965_decode_urb_fence(data, hw_offset, len, count,
2831 instr_out(data, hw_offset, 0, "CS_URB_STATE\n");
2832 instr_out(data, hw_offset, 1,
2833 "entry_size: %d [%d bytes], n_entries: %d\n",
2834 (data[1] >> 4) & 0x1f,
2835 (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7);
2838 len = (data[0] & 0x000000ff) + 2;
2839 instr_out(data, hw_offset, 0, "CONSTANT_BUFFER: %s\n",
2840 (data[0] >> 8) & 1 ? "valid" : "invalid");
2841 instr_out(data, hw_offset, 1,
2842 "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f,
2843 ((data[1] & 0x3f) + 1) * 64);
2847 instr_out(data, hw_offset, 0, "STATE_BASE_ADDRESS\n");
2850 if (IS_GEN6(devid) || IS_GEN7(devid))
2852 else if (IS_GEN5(devid))
2857 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
2859 BUFFER_FAIL(count, len, "STATE_BASE_ADDRESS");
2861 state_base_out(data, hw_offset, i++, "general");
2862 state_base_out(data, hw_offset, i++, "surface");
2863 if (IS_GEN6(devid) || IS_GEN7(devid))
2864 state_base_out(data, hw_offset, i++, "dynamic");
2865 state_base_out(data, hw_offset, i++, "indirect");
2866 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2867 state_base_out(data, hw_offset, i++, "instruction");
2869 state_max_out(data, hw_offset, i++, "general");
2870 if (IS_GEN6(devid) || IS_GEN7(devid))
2871 state_max_out(data, hw_offset, i++, "dynamic");
2872 state_max_out(data, hw_offset, i++, "indirect");
2873 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2874 state_max_out(data, hw_offset, i++, "instruction");
2880 "Bad count in 3DSTATE_PIPELINED_POINTERS\n");
2882 BUFFER_FAIL(count, len, "3DSTATE_PIPELINED_POINTERS");
2884 instr_out(data, hw_offset, 0, "3DSTATE_PIPELINED_POINTERS\n");
2885 instr_out(data, hw_offset, 1, "VS state\n");
2886 instr_out(data, hw_offset, 2, "GS state\n");
2887 instr_out(data, hw_offset, 3, "Clip state\n");
2888 instr_out(data, hw_offset, 4, "SF state\n");
2889 instr_out(data, hw_offset, 5, "WM state\n");
2890 instr_out(data, hw_offset, 6, "CC state\n");
2893 len = (data[0] & 0x000000ff) + 2;
2894 if (len != 6 && len != 4)
2896 "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
2899 BUFFER_FAIL(count, len,
2900 "3DSTATE_BINDING_TABLE_POINTERS");
2901 instr_out(data, hw_offset, 0,
2902 "3DSTATE_BINDING_TABLE_POINTERS\n");
2903 instr_out(data, hw_offset, 1, "VS binding table\n");
2904 instr_out(data, hw_offset, 2, "GS binding table\n");
2905 instr_out(data, hw_offset, 3, "Clip binding table\n");
2906 instr_out(data, hw_offset, 4, "SF binding table\n");
2907 instr_out(data, hw_offset, 5, "WM binding table\n");
2910 BUFFER_FAIL(count, len,
2911 "3DSTATE_BINDING_TABLE_POINTERS");
2913 instr_out(data, hw_offset, 0,
2914 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
2915 "GS mod %d, PS mod %d\n",
2916 (data[0] & (1 << 8)) != 0,
2917 (data[0] & (1 << 9)) != 0,
2918 (data[0] & (1 << 12)) != 0);
2919 instr_out(data, hw_offset, 1, "VS binding table\n");
2920 instr_out(data, hw_offset, 2, "GS binding table\n");
2921 instr_out(data, hw_offset, 3, "WM binding table\n");
2926 len = (data[0] & 0xff) + 2;
2929 "Bad count in 3DSTATE_SAMPLER_STATE_POINTERS\n");
2931 BUFFER_FAIL(count, len,
2932 "3DSTATE_SAMPLER_STATE_POINTERS");
2933 instr_out(data, hw_offset, 0,
2934 "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
2935 "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
2936 (data[0] & (1 << 9)) != 0,
2937 (data[0] & (1 << 12)) != 0);
2938 instr_out(data, hw_offset, 1, "VS sampler state\n");
2939 instr_out(data, hw_offset, 2, "GS sampler state\n");
2940 instr_out(data, hw_offset, 3, "WM sampler state\n");
2943 len = (data[0] & 0xff) + 2;
2945 fprintf(out, "Bad count in 3DSTATE_URB\n");
2947 BUFFER_FAIL(count, len, "3DSTATE_URB");
2948 instr_out(data, hw_offset, 0, "3DSTATE_URB\n");
2949 instr_out(data, hw_offset, 1,
2950 "VS entries %d, alloc size %d (1024bit row)\n",
2951 data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1);
2952 instr_out(data, hw_offset, 2,
2953 "GS entries %d, alloc size %d (1024bit row)\n",
2954 (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1);
2958 len = (data[0] & 0xff) + 2;
2959 if ((len - 1) % 4 != 0)
2960 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
2962 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_BUFFERS");
2963 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_BUFFERS\n");
2965 for (i = 1; i < len;) {
2967 if (IS_GEN6(devid)) {
2974 instr_out(data, hw_offset, i,
2975 "buffer %d: %s, pitch %db\n", data[i] >> idx,
2976 data[i] & (1 << access) ? "random" :
2977 "sequential", data[i] & 0x07ff);
2979 instr_out(data, hw_offset, i++, "buffer address\n");
2980 instr_out(data, hw_offset, i++, "max index\n");
2981 instr_out(data, hw_offset, i++, "mbz\n");
2986 len = (data[0] & 0xff) + 2;
2987 if ((len + 1) % 2 != 0)
2988 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
2990 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_ELEMENTS");
2991 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_ELEMENTS\n");
2993 for (i = 1; i < len;) {
2994 instr_out(data, hw_offset, i,
2995 "buffer %d: %svalid, type 0x%04x, "
2996 "src offset 0x%04x bytes\n",
2997 data[i] >> (IS_GEN6(devid) ? 26 : 27),
2998 data[i] & (1 << (IS_GEN6(devid) ? 25 : 26)) ?
2999 "" : "in", (data[i] >> 16) & 0x1ff,
3002 instr_out(data, hw_offset, i, "(%s, %s, %s, %s), "
3003 "dst offset 0x%02x bytes\n",
3004 get_965_element_component(data[i], 0),
3005 get_965_element_component(data[i], 1),
3006 get_965_element_component(data[i], 2),
3007 get_965_element_component(data[i], 3),
3008 (data[i] & 0xff) * 4);
3014 len = (data[0] & 0xff) + 2;
3017 "Bad count in 3DSTATE_VIEWPORT_STATE_POINTERS\n");
3019 BUFFER_FAIL(count, len,
3020 "3DSTATE_VIEWPORT_STATE_POINTERS");
3021 instr_out(data, hw_offset, 0,
3022 "3DSTATE_VIEWPORT_STATE_POINTERS\n");
3023 instr_out(data, hw_offset, 1, "clip\n");
3024 instr_out(data, hw_offset, 2, "sf\n");
3025 instr_out(data, hw_offset, 3, "cc\n");
3029 len = (data[0] & 0xff) + 2;
3031 fprintf(out, "Bad count in 3DSTATE_INDEX_BUFFER\n");
3033 BUFFER_FAIL(count, len, "3DSTATE_INDEX_BUFFER");
3034 instr_out(data, hw_offset, 0, "3DSTATE_INDEX_BUFFER\n");
3035 instr_out(data, hw_offset, 1, "beginning buffer address\n");
3036 instr_out(data, hw_offset, 2, "ending buffer address\n");
3040 len = (data[0] & 0xff) + 2;
3043 "Bad count in 3DSTATE_CC_STATE_POINTERS\n");
3045 BUFFER_FAIL(count, len, "3DSTATE_CC_STATE_POINTERS");
3046 instr_out(data, hw_offset, 0, "3DSTATE_CC_STATE_POINTERS\n");
3047 instr_out(data, hw_offset, 1, "blend change %d\n", data[1] & 1);
3048 instr_out(data, hw_offset, 2, "depth stencil change %d\n",
3050 instr_out(data, hw_offset, 3, "cc change %d\n", data[3] & 1);
3054 len = (data[0] & 0xff) + 2;
3056 fprintf(out, "Bad count in 3DSTATE_SCISSOR_POINTERS\n");
3058 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_POINTERS");
3059 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_POINTERS\n");
3060 instr_out(data, hw_offset, 1, "scissor rect offset\n");
3064 len = (data[0] & 0xff) + 2;
3066 fprintf(out, "Bad count in 3DSTATE_VS\n");
3068 BUFFER_FAIL(count, len, "3DSTATE_VS");
3069 instr_out(data, hw_offset, 0, "3DSTATE_VS\n");
3070 instr_out(data, hw_offset, 1, "kernel pointer\n");
3071 instr_out(data, hw_offset, 2,
3072 "SPF=%d, VME=%d, Sampler Count %d, "
3073 "Binding table count %d\n", (data[2] >> 31) & 1,
3074 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3075 (data[2] >> 18) & 0xff);
3076 instr_out(data, hw_offset, 3, "scratch offset\n");
3077 instr_out(data, hw_offset, 4,
3078 "Dispatch GRF start %d, VUE read length %d, "
3079 "VUE read offset %d\n", (data[4] >> 20) & 0x1f,
3080 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3081 instr_out(data, hw_offset, 5,
3082 "Max Threads %d, Vertex Cache %sable, "
3083 "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1,
3084 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
3085 (data[5] & 1) != 0 ? "en" : "dis");
3089 len = (data[0] & 0xff) + 2;
3091 fprintf(out, "Bad count in 3DSTATE_GS\n");
3093 BUFFER_FAIL(count, len, "3DSTATE_GS");
3094 instr_out(data, hw_offset, 0, "3DSTATE_GS\n");
3095 instr_out(data, hw_offset, 1, "kernel pointer\n");
3096 instr_out(data, hw_offset, 2,
3097 "SPF=%d, VME=%d, Sampler Count %d, "
3098 "Binding table count %d\n", (data[2] >> 31) & 1,
3099 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3100 (data[2] >> 18) & 0xff);
3101 instr_out(data, hw_offset, 3, "scratch offset\n");
3102 instr_out(data, hw_offset, 4,
3103 "Dispatch GRF start %d, VUE read length %d, "
3104 "VUE read offset %d\n", (data[4] & 0xf),
3105 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3106 instr_out(data, hw_offset, 5,
3107 "Max Threads %d, Rendering %sable\n",
3108 ((data[5] >> 25) & 0x7f) + 1,
3109 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
3110 instr_out(data, hw_offset, 6,
3111 "Reorder %sable, Discard Adjaceny %sable, "
3113 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
3114 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
3115 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
3119 len = (data[0] & 0xff) + 2;
3121 fprintf(out, "Bad count in 3DSTATE_CLIP\n");
3123 BUFFER_FAIL(count, len, "3DSTATE_CLIP");
3124 instr_out(data, hw_offset, 0, "3DSTATE_CLIP\n");
3125 instr_out(data, hw_offset, 1,
3126 "UserClip distance cull test mask 0x%x\n",
3128 instr_out(data, hw_offset, 2,
3129 "Clip %sable, API mode %s, Viewport XY test %sable, "
3130 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
3131 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
3132 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
3133 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
3134 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
3135 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
3136 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
3137 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
3138 (data[2] >> 13) & 7,
3139 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
3140 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
3141 (data[2] >> 4) & 3, (data[2] >> 2) & 3,
3143 instr_out(data, hw_offset, 3,
3144 "Min PointWidth %d, Max PointWidth %d, "
3145 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
3146 (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff,
3147 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
3152 len = (data[0] & 0xff) + 2;
3154 fprintf(out, "Bad count in 3DSTATE_SF\n");
3156 BUFFER_FAIL(count, len, "3DSTATE_SF");
3157 instr_out(data, hw_offset, 0, "3DSTATE_SF\n");
3158 instr_out(data, hw_offset, 1,
3159 "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
3160 "VUE read offset %d\n", (data[1] >> 22) & 0x3f,
3161 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
3162 (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f);
3163 instr_out(data, hw_offset, 2,
3164 "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
3165 "VP transform %sable, FrontWinding_%s\n",
3166 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
3167 (data[2] >> 5) & 3, (data[2] >> 3) & 3,
3168 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
3169 (data[2] & 1) != 0 ? "CCW" : "CW");
3170 instr_out(data, hw_offset, 3,
3171 "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
3172 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
3173 (data[3] >> 29) & 3,
3174 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
3175 (data[3] >> 8) & 3);
3176 instr_out(data, hw_offset, 4,
3177 "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
3178 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
3179 (data[4] & (1 << 12)) != 0 ? 4 : 8,
3180 (data[4] & (1 << 11)) != 0);
3181 instr_out(data, hw_offset, 5,
3182 "Global Depth Offset Constant %f\n", data[5]);
3183 instr_out(data, hw_offset, 6, "Global Depth Offset Scale %f\n",
3185 instr_out(data, hw_offset, 7, "Global Depth Offset Clamp %f\n",
3188 for (i = 0, j = 0; i < 8; i++, j += 2)
3189 instr_out(data, hw_offset, i + 8,
3190 "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, "
3191 "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n",
3193 (data[8 + i] & (1 << 31)) != 0 ? "W" : "",
3194 (data[8 + i] & (1 << 30)) != 0 ? "Z" : "",
3195 (data[8 + i] & (1 << 29)) != 0 ? "Y" : "",
3196 (data[8 + i] & (1 << 28)) != 0 ? "X" : "",
3197 (data[8 + i] >> 25) & 3,
3198 (data[8 + i] >> 22) & 3,
3199 (data[8 + i] >> 16) & 0x1f, j,
3200 (data[8 + i] & (1 << 15)) != 0 ? "W" : "",
3201 (data[8 + i] & (1 << 14)) != 0 ? "Z" : "",
3202 (data[8 + i] & (1 << 13)) != 0 ? "Y" : "",
3203 (data[8 + i] & (1 << 12)) != 0 ? "X" : "",
3204 (data[8 + i] >> 9) & 3,
3205 (data[8 + i] >> 6) & 3, (data[8 + i] & 0x1f));
3206 instr_out(data, hw_offset, 16,
3207 "Point Sprite TexCoord Enable\n");
3208 instr_out(data, hw_offset, 17, "Const Interp Enable\n");
3209 instr_out(data, hw_offset, 18,
3210 "Attrib 7-0 WrapShortest Enable\n");
3211 instr_out(data, hw_offset, 19,
3212 "Attrib 15-8 WrapShortest Enable\n");
3217 len = (data[0] & 0xff) + 2;
3219 fprintf(out, "Bad count in 3DSTATE_WM\n");
3221 BUFFER_FAIL(count, len, "3DSTATE_WM");
3222 instr_out(data, hw_offset, 0, "3DSTATE_WM\n");
3223 instr_out(data, hw_offset, 1, "kernel start pointer 0\n");
3224 instr_out(data, hw_offset, 2,
3225 "SPF=%d, VME=%d, Sampler Count %d, "
3226 "Binding table count %d\n", (data[2] >> 31) & 1,
3227 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3228 (data[2] >> 18) & 0xff);
3229 instr_out(data, hw_offset, 3, "scratch offset\n");
3230 instr_out(data, hw_offset, 4,
3231 "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
3232 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
3233 (data[4] & (1 << 30)) != 0,
3234 (data[4] & (1 << 28)) != 0,
3235 (data[4] & (1 << 27)) != 0, (data[4] >> 16) & 0x7f,
3236 (data[4] >> 8) & 0x7f, (data[4] & 0x7f));
3237 instr_out(data, hw_offset, 5,
3238 "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
3239 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, Dispatch32 %d, "
3240 "Dispatch16 %d, Dispatch8 %d\n",
3241 ((data[5] >> 25) & 0x7f) + 1,
3242 (data[5] & (1 << 22)) != 0,
3243 (data[5] & (1 << 21)) != 0,
3244 (data[5] & (1 << 20)) != 0,
3245 (data[5] & (1 << 19)) != 0, (data[5] & (1 << 8)) != 0,
3246 (data[5] & (1 << 2)) != 0, (data[5] & (1 << 1)) != 0,
3247 (data[5] & (1 << 0)) != 0);
3248 instr_out(data, hw_offset, 6,
3249 "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
3250 "Barycentric interp mode 0x%x, Point raster rule %d, Multisample mode %d, "
3251 "Multisample Dispatch mode %d\n",
3252 (data[6] >> 20) & 0x3f, (data[6] >> 18) & 3,
3253 (data[6] >> 16) & 3, (data[6] >> 10) & 0x3f,
3254 (data[6] & (1 << 9)) != 0, (data[6] >> 1) & 3,
3256 instr_out(data, hw_offset, 7, "kernel start pointer 1\n");
3257 instr_out(data, hw_offset, 8, "kernel start pointer 2\n");
3264 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
3266 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
3268 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
3269 instr_out(data, hw_offset, 1, "top left: %d,%d\n",
3270 data[1] & 0xffff, (data[1] >> 16) & 0xffff);
3271 instr_out(data, hw_offset, 2, "bottom right: %d,%d\n",
3272 data[2] & 0xffff, (data[2] >> 16) & 0xffff);
3273 instr_out(data, hw_offset, 3, "origin: %d,%d\n",
3274 (int)data[3] & 0xffff, ((int)data[3] >> 16) & 0xffff);
3279 if (len < 5 || len > 7)
3280 fprintf(out, "Bad count in 3DSTATE_DEPTH_BUFFER\n");
3282 BUFFER_FAIL(count, len, "3DSTATE_DEPTH_BUFFER");
3284 instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_BUFFER\n");
3285 if (IS_GEN5(devid) || IS_GEN6(devid))
3286 instr_out(data, hw_offset, 1,
3287 "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
3288 get_965_surfacetype(data[1] >> 29),
3289 get_965_depthformat((data[1] >> 18) & 0x7),
3290 (data[1] & 0x0001ffff) + 1,
3291 data[1] & (1 << 27) ? "" : "not ",
3292 (data[1] & (1 << 22)) != 0,
3293 (data[1] & (1 << 21)) != 0);
3295 instr_out(data, hw_offset, 1,
3296 "%s, %s, pitch = %d bytes, %stiled\n",
3297 get_965_surfacetype(data[1] >> 29),
3298 get_965_depthformat((data[1] >> 18) & 0x7),
3299 (data[1] & 0x0001ffff) + 1,
3300 data[1] & (1 << 27) ? "" : "not ");
3301 instr_out(data, hw_offset, 2, "depth offset\n");
3302 instr_out(data, hw_offset, 3, "%dx%d\n",
3303 ((data[3] & 0x0007ffc0) >> 6) + 1,
3304 ((data[3] & 0xfff80000) >> 19) + 1);
3305 instr_out(data, hw_offset, 4, "volume depth\n");
3307 instr_out(data, hw_offset, 5, "\n");
3310 instr_out(data, hw_offset, 6, "\n");
3312 instr_out(data, hw_offset, 6,
3313 "render target view extent\n");
3319 if (IS_GEN6(devid) || IS_GEN7(devid)) {
3321 len = (data[0] & 0xff) + 2;
3322 if (len != 4 && len != 5)
3323 fprintf(out, "Bad count in PIPE_CONTROL\n");
3325 BUFFER_FAIL(count, len, "PIPE_CONTROL");
3327 switch ((data[1] >> 14) & 0x3) {
3332 desc1 = "qword write";
3335 desc1 = "PS_DEPTH_COUNT write";
3338 desc1 = "TIMESTAMP write";
3341 instr_out(data, hw_offset, 0, "PIPE_CONTROL\n");
3342 instr_out(data, hw_offset, 1,
3343 "%s, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
3345 data[1] & (1 << 20) ? "cs stall, " : "",
3346 data[1] & (1 << 19) ?
3347 "global snapshot count reset, " : "",
3348 data[1] & (1 << 18) ? "tlb invalidate, " : "",
3349 data[1] & (1 << 17) ? "gfdt flush, " : "",
3350 data[1] & (1 << 17) ? "media state clear, " :
3352 data[1] & (1 << 13) ? "depth stall, " : "",
3353 data[1] & (1 << 12) ?
3354 "render target cache flush, " : "",
3355 data[1] & (1 << 11) ?
3356 "instruction cache invalidate, " : "",
3357 data[1] & (1 << 10) ?
3358 "texture cache invalidate, " : "",
3359 data[1] & (1 << 9) ?
3360 "indirect state invalidate, " : "",
3361 data[1] & (1 << 8) ? "notify irq, " : "",
3362 data[1] & (1 << 7) ? "PIPE_CONTROL flush, " :
3364 data[1] & (1 << 6) ? "protect mem app_id, " :
3365 "", data[1] & (1 << 5) ? "DC flush, " : "",
3366 data[1] & (1 << 4) ? "vf fetch invalidate, " :
3368 data[1] & (1 << 3) ?
3369 "constant cache invalidate, " : "",
3370 data[1] & (1 << 2) ?
3371 "state cache invalidate, " : "",
3372 data[1] & (1 << 1) ? "stall at scoreboard, " :
3374 data[1] & (1 << 0) ? "depth cache flush, " :
3377 instr_out(data, hw_offset, 2,
3378 "destination address\n");
3379 instr_out(data, hw_offset, 3,
3380 "immediate dword low\n");
3381 instr_out(data, hw_offset, 4,
3382 "immediate dword high\n");
3384 for (i = 2; i < len; i++) {
3385 instr_out(data, hw_offset, i, "\n");
3390 len = (data[0] & 0xff) + 2;
3392 fprintf(out, "Bad count in PIPE_CONTROL\n");
3394 BUFFER_FAIL(count, len, "PIPE_CONTROL");
3396 switch ((data[0] >> 14) & 0x3) {
3401 desc1 = "qword write";
3404 desc1 = "PS_DEPTH_COUNT write";
3407 desc1 = "TIMESTAMP write";
3410 instr_out(data, hw_offset, 0,
3411 "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, "
3414 data[0] & (1 << 13) ? "" : "no ",
3415 data[0] & (1 << 12) ? "" : "no ",
3416 data[0] & (1 << 11) ? "" : "no ");
3417 instr_out(data, hw_offset, 1, "destination address\n");
3418 instr_out(data, hw_offset, 2, "immediate dword low\n");
3419 instr_out(data, hw_offset, 3, "immediate dword high\n");
3423 len = (data[0] & 0xff) + 2;
3425 fprintf(out, "Bad count in 3DPRIMITIVE\n");
3427 BUFFER_FAIL(count, len, "3DPRIMITIVE");
3429 instr_out(data, hw_offset, 0,
3430 "3DPRIMITIVE: %s %s\n",
3431 get_965_prim_type(data[0]),
3432 (data[0] & (1 << 15)) ? "random" : "sequential");
3433 instr_out(data, hw_offset, 1, "vertex count\n");
3434 instr_out(data, hw_offset, 2, "start vertex\n");
3435 instr_out(data, hw_offset, 3, "instance count\n");
3436 instr_out(data, hw_offset, 4, "start instance\n");
3437 instr_out(data, hw_offset, 5, "index bias\n");
3441 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3442 opcode_3d = &opcodes_3d[idx];
3443 if ((data[0] & 0xffff0000) >> 16 == opcode_3d->opcode) {
3447 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
3448 if (opcode_3d->max_len > 1) {
3449 len = (data[0] & 0xff) + 2;
3450 if (len < opcode_3d->min_len ||
3451 len > opcode_3d->max_len) {
3452 fprintf(out, "Bad count in %s\n",
3457 for (i = 1; i < len; i++) {
3459 BUFFER_FAIL(count, len,
3461 instr_out(data, hw_offset, i, "dword %d\n", i);
3467 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n",
3474 decode_3d_i830(uint32_t *data, uint32_t count, uint32_t hw_offset, uint32_t devid,
3482 unsigned int min_len;
3483 unsigned int max_len;
3486 { 0x02, 1, 1, "3DSTATE_MODES_3" },
3487 { 0x03, 1, 1, "3DSTATE_ENABLES_1" },
3488 { 0x04, 1, 1, "3DSTATE_ENABLES_2" },
3489 { 0x05, 1, 1, "3DSTATE_VFT0" },
3490 { 0x06, 1, 1, "3DSTATE_AA" },
3491 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
3492 { 0x08, 1, 1, "3DSTATE_MODES_1" },
3493 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
3494 { 0x0a, 1, 1, "3DSTATE_VFT1" },
3495 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
3496 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
3497 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
3498 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
3499 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
3500 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
3501 { 0x16, 1, 1, "3DSTATE_MODES_4"},
3504 opcode = (data[0] & 0x1f000000) >> 24;
3508 return decode_3d_primitive(data, count, hw_offset, failures);
3510 return decode_3d_1d(data, count, hw_offset, devid, failures);
3512 return decode_3d_1c(data, count, hw_offset, failures);
3515 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3516 opcode_3d = &opcodes_3d[idx];
3517 if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) {
3518 unsigned int len = 1, i;
3520 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
3521 if (opcode_3d->max_len > 1) {
3522 len = (data[0] & 0xff) + 2;
3523 if (len < opcode_3d->min_len ||
3524 len > opcode_3d->max_len) {
3525 fprintf(out, "Bad count in %s\n",
3530 for (i = 1; i < len; i++) {
3532 BUFFER_FAIL(count, len,
3534 instr_out(data, hw_offset, i, "dword %d\n", i);
3540 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n",
3546 struct drm_intel_decode *
3547 drm_intel_decode_context_alloc(uint32_t devid)
3549 struct drm_intel_decode *ctx;
3551 ctx = calloc(1, sizeof(struct drm_intel_decode));
3561 drm_intel_decode_context_free(struct drm_intel_decode *ctx)
3567 drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
3570 ctx->dump_past_end = !!dump_past_end;
3574 drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx,
3575 void *data, uint32_t hw_offset, int count)
3578 ctx->hw_offset = hw_offset;
3583 drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
3584 uint32_t head, uint32_t tail)
3591 * Decodes an i830-i915 batch buffer, writing the output to stdout.
3593 * \param data batch buffer contents
3594 * \param count number of DWORDs to decode in the batch buffer
3595 * \param hw_offset hardware address for the buffer
3598 drm_intel_decode(struct drm_intel_decode *ctx)
3601 unsigned int index = 0;
3604 uint32_t count, hw_offset;
3612 hw_offset = ctx->hw_offset;
3614 head_offset = ctx->head;
3615 tail_offset = ctx->tail;
3622 while (index < count) {
3623 switch ((data[index] & 0xe0000000) >> 29) {
3625 ret = decode_mi(data + index, count - index,
3626 hw_offset + index * 4, &failures);
3628 /* If MI_BATCHBUFFER_END happened, then dump
3629 * the rest of the output in case we some day
3630 * want it in debugging, but don't decode it
3631 * since it'll just confuse in the common
3635 if (ctx->dump_past_end) {
3638 for (index = index + 1; index < count;
3640 instr_out(data, hw_offset,
3648 index += decode_2d(data + index, count - index,
3649 hw_offset + index * 4, &failures);
3652 if (IS_9XX(devid) && !IS_GEN3(devid)) {
3654 decode_3d_965(data + index, count - index,
3655 hw_offset + index * 4, devid,
3657 } else if (IS_GEN3(devid)) {
3658 index += decode_3d(data + index, count - index,
3659 hw_offset + index * 4,
3663 decode_3d_i830(data + index, count - index,
3664 hw_offset + index * 4, devid,
3669 instr_out(data, hw_offset, index, "UNKNOWN\n");