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,
92 const char *fmt, ...) __attribute__((format(__printf__, 4, 5)));
95 instr_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
99 const char *parseinfo;
100 uint32_t offset = hw_offset + index * 4;
102 if (offset == head_offset)
104 else if (offset == tail_offset)
109 fprintf(out, "0x%08x: %s 0x%08x: %s", offset, parseinfo,
110 data[index], index == 0 ? "" : " ");
112 vfprintf(out, fmt, va);
117 decode_mi(uint32_t *data, uint32_t count, uint32_t hw_offset, int *failures)
119 unsigned int opcode, len = -1;
120 const char *post_sync_op = "";
125 unsigned int min_len;
126 unsigned int max_len;
129 { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" },
130 { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" },
131 { 0x30, 0x3f, 3, 3, "MI_BATCH_BUFFER" },
132 { 0x31, 0x3f, 2, 2, "MI_BATCH_BUFFER_START" },
133 { 0x14, 0x3f, 3, 3, "MI_DISPLAY_BUFFER_INFO" },
134 { 0x04, 0, 1, 1, "MI_FLUSH" },
135 { 0x22, 0x1f, 3, 3, "MI_LOAD_REGISTER_IMM" },
136 { 0x13, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" },
137 { 0x12, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_INCL" },
138 { 0x00, 0, 1, 1, "MI_NOOP" },
139 { 0x11, 0x3f, 2, 2, "MI_OVERLAY_FLIP" },
140 { 0x07, 0, 1, 1, "MI_REPORT_HEAD" },
141 { 0x18, 0x3f, 2, 2, "MI_SET_CONTEXT" },
142 { 0x20, 0x3f, 3, 4, "MI_STORE_DATA_IMM" },
143 { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" },
144 { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" },
145 { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" },
146 { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT" },
147 { 0x16, 0x7f, 3, 3, "MI_SEMAPHORE_MBOX" },
148 { 0x26, 0x1f, 3, 4, "MI_FLUSH_DW" },
149 { 0x0b, 0, 1, 1, "MI_SUSPEND_FLUSH"},
152 /* check instruction length */
153 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
155 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
157 if (opcodes_mi[opcode].max_len > 1) {
159 (data[0] & opcodes_mi[opcode].len_mask) + 2;
160 if (len < opcodes_mi[opcode].min_len
161 || len > opcodes_mi[opcode].max_len) {
163 "Bad length (%d) in %s, [%d, %d]\n",
164 len, opcodes_mi[opcode].name,
165 opcodes_mi[opcode].min_len,
166 opcodes_mi[opcode].max_len);
173 switch ((data[0] & 0x1f800000) >> 23) {
175 instr_out(data, hw_offset, 0, "MI_BATCH_BUFFER_END\n");
178 instr_out(data, hw_offset, 0, "MI_SEMAPHORE_MBOX%s%s%s%s %u\n",
179 data[0] & (1 << 22) ? " global gtt," : "",
180 data[0] & (1 << 21) ? " update semaphore," : "",
181 data[0] & (1 << 20) ? " compare semaphore," : "",
182 data[0] & (1 << 18) ? " use compare reg" : "",
183 (data[0] & (0x3 << 16)) >> 16);
184 instr_out(data, hw_offset, 1, "value\n");
185 instr_out(data, hw_offset, 2, "address\n");
188 instr_out(data, hw_offset, 0, "MI_STORE_DATA_INDEX%s\n",
189 data[0] & (1 << 21) ? " use per-process HWS," : "");
190 instr_out(data, hw_offset, 1, "index\n");
191 instr_out(data, hw_offset, 2, "dword\n");
193 instr_out(data, hw_offset, 3, "upper dword\n");
196 if (data[0] & (1 << 22))
197 instr_out(data, hw_offset, 0,
198 "MI_NOOP write NOPID reg, val=0x%x\n",
199 data[0] & ((1 << 22) - 1));
201 instr_out(data, hw_offset, 0, "MI_NOOP\n");
204 switch (data[0] & (0x3 << 14)) {
206 post_sync_op = "no write";
209 post_sync_op = "write data";
212 post_sync_op = "reserved";
215 post_sync_op = "write TIMESTAMP";
218 instr_out(data, hw_offset, 0,
219 "MI_FLUSH_DW%s%s%s%s post_sync_op='%s' %s%s\n",
220 data[0] & (1 << 22) ?
221 " enable protected mem (BCS-only)," : "",
222 data[0] & (1 << 21) ? " store in hws," : "",
223 data[0] & (1 << 18) ? " invalidate tlb," : "",
224 data[0] & (1 << 17) ? " flush gfdt," : "",
226 data[0] & (1 << 8) ? " enable notify interrupt," : "",
228 " invalidate video state (BCS-only)," : "");
229 if (data[0] & (1 << 21))
230 instr_out(data, hw_offset, 1, "hws index\n");
232 instr_out(data, hw_offset, 1, "address\n");
233 instr_out(data, hw_offset, 2, "dword\n");
235 instr_out(data, hw_offset, 3, "upper dword\n");
239 for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]);
241 if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) {
244 instr_out(data, hw_offset, 0, "%s\n",
245 opcodes_mi[opcode].name);
246 for (i = 1; i < len; i++) {
248 BUFFER_FAIL(count, len,
249 opcodes_mi[opcode].name);
250 instr_out(data, hw_offset, i, "dword %d\n", i);
257 instr_out(data, hw_offset, 0, "MI UNKNOWN\n");
263 decode_2d_br00(uint32_t *data, uint32_t count, uint32_t hw_offset,
266 instr_out(data, hw_offset, 0,
267 "%s (rgb %sabled, alpha %sabled, src tile %d, dst tile %d)\n",
269 (data[count] & (1 << 20)) ? "en" : "dis",
270 (data[count] & (1 << 21)) ? "en" : "dis",
271 (data[count] >> 15) & 1, (data[count] >> 11) & 1);
274 static void decode_2d_br01(uint32_t *data, uint32_t count, uint32_t hw_offset)
277 switch ((data[count] >> 24) & 0x3) {
292 instr_out(data, hw_offset, count, "format %s, pitch %d, rop 0x%02x, "
293 "clipping %sabled, %s%s \n",
295 (short)(data[count] & 0xffff),
296 (data[count] >> 16) & 0xff,
297 data[count] & (1 << 30) ? "en" : "dis",
298 data[count] & (1 << 31) ? "solid pattern enabled, " : "",
299 data[count] & (1 << 31) ?
300 "mono pattern transparency enabled, " : "");
305 decode_2d(uint32_t *data, uint32_t count, uint32_t hw_offset, int *failures)
307 unsigned int opcode, len;
311 unsigned int min_len;
312 unsigned int max_len;
315 { 0x40, 5, 5, "COLOR_BLT" },
316 { 0x43, 6, 6, "SRC_COPY_BLT" },
317 { 0x01, 8, 8, "XY_SETUP_BLT" },
318 { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" },
319 { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" },
320 { 0x24, 2, 2, "XY_PIXEL_BLT" },
321 { 0x25, 3, 3, "XY_SCANLINES_BLT" },
322 { 0x26, 4, 4, "Y_TEXT_BLT" },
323 { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" },
324 { 0x50, 6, 6, "XY_COLOR_BLT" },
325 { 0x51, 6, 6, "XY_PAT_BLT" },
326 { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" },
327 { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" },
328 { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" },
329 { 0x52, 9, 9, "XY_MONO_PAT_BLT" },
330 { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" },
331 { 0x53, 8, 8, "XY_SRC_COPY_BLT" },
332 { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" },
333 { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" },
334 { 0x55, 9, 9, "XY_FULL_BLT" },
335 { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" },
336 { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" },
337 { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" },
338 { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" },
339 { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT"},
342 switch ((data[0] & 0x1fc00000) >> 22) {
344 instr_out(data, hw_offset, 0,
345 "XY_SCANLINES_BLT (pattern seed (%d, %d), dst tile %d)\n",
346 (data[0] >> 12) & 0x8,
347 (data[0] >> 8) & 0x8, (data[0] >> 11) & 1);
349 len = (data[0] & 0x000000ff) + 2;
351 fprintf(out, "Bad count in XY_SCANLINES_BLT\n");
353 BUFFER_FAIL(count, len, "XY_SCANLINES_BLT");
355 instr_out(data, hw_offset, 1, "dest (%d,%d)\n",
356 data[1] & 0xffff, data[1] >> 16);
357 instr_out(data, hw_offset, 2, "dest (%d,%d)\n",
358 data[2] & 0xffff, data[2] >> 16);
361 decode_2d_br00(data, 0, hw_offset, "XY_SETUP_BLT");
363 len = (data[0] & 0x000000ff) + 2;
365 fprintf(out, "Bad count in XY_SETUP_BLT\n");
367 BUFFER_FAIL(count, len, "XY_SETUP_BLT");
369 decode_2d_br01(data, 1, hw_offset);
370 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
371 data[2] & 0xffff, data[2] >> 16);
372 instr_out(data, hw_offset, 3, "cliprect (%d,%d)\n",
373 data[3] & 0xffff, data[3] >> 16);
374 instr_out(data, hw_offset, 4, "setup dst offset 0x%08x\n",
376 instr_out(data, hw_offset, 5, "setup background color\n");
377 instr_out(data, hw_offset, 6, "setup foreground color\n");
378 instr_out(data, hw_offset, 7, "color pattern offset\n");
381 decode_2d_br00(data, 0, hw_offset, "XY_SETUP_CLIP_BLT");
383 len = (data[0] & 0x000000ff) + 2;
385 fprintf(out, "Bad count in XY_SETUP_CLIP_BLT\n");
387 BUFFER_FAIL(count, len, "XY_SETUP_CLIP_BLT");
389 instr_out(data, hw_offset, 1, "cliprect (%d,%d)\n",
390 data[1] & 0xffff, data[2] >> 16);
391 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
392 data[2] & 0xffff, data[3] >> 16);
395 decode_2d_br00(data, 0, hw_offset,
396 "XY_SETUP_MONO_PATTERN_SL_BLT");
398 len = (data[0] & 0x000000ff) + 2;
401 "Bad count in XY_SETUP_MONO_PATTERN_SL_BLT\n");
403 BUFFER_FAIL(count, len, "XY_SETUP_MONO_PATTERN_SL_BLT");
405 decode_2d_br01(data, 1, hw_offset);
406 instr_out(data, hw_offset, 2, "cliprect (%d,%d)\n",
407 data[2] & 0xffff, data[2] >> 16);
408 instr_out(data, hw_offset, 3, "cliprect (%d,%d)\n",
409 data[3] & 0xffff, data[3] >> 16);
410 instr_out(data, hw_offset, 4, "setup dst offset 0x%08x\n",
412 instr_out(data, hw_offset, 5, "setup background color\n");
413 instr_out(data, hw_offset, 6, "setup foreground color\n");
414 instr_out(data, hw_offset, 7, "mono pattern dw0\n");
415 instr_out(data, hw_offset, 8, "mono pattern dw1\n");
418 decode_2d_br00(data, 0, hw_offset, "XY_COLOR_BLT");
420 len = (data[0] & 0x000000ff) + 2;
422 fprintf(out, "Bad count in XY_COLOR_BLT\n");
424 BUFFER_FAIL(count, len, "XY_COLOR_BLT");
426 decode_2d_br01(data, 1, hw_offset);
427 instr_out(data, hw_offset, 2, "(%d,%d)\n",
428 data[2] & 0xffff, data[2] >> 16);
429 instr_out(data, hw_offset, 3, "(%d,%d)\n",
430 data[3] & 0xffff, data[3] >> 16);
431 instr_out(data, hw_offset, 4, "offset 0x%08x\n", data[4]);
432 instr_out(data, hw_offset, 5, "color\n");
435 decode_2d_br00(data, 0, hw_offset, "XY_SRC_COPY_BLT");
437 len = (data[0] & 0x000000ff) + 2;
439 fprintf(out, "Bad count in XY_SRC_COPY_BLT\n");
441 BUFFER_FAIL(count, len, "XY_SRC_COPY_BLT");
443 decode_2d_br01(data, 1, hw_offset);
444 instr_out(data, hw_offset, 2, "dst (%d,%d)\n",
445 data[2] & 0xffff, data[2] >> 16);
446 instr_out(data, hw_offset, 3, "dst (%d,%d)\n",
447 data[3] & 0xffff, data[3] >> 16);
448 instr_out(data, hw_offset, 4, "dst offset 0x%08x\n", data[4]);
449 instr_out(data, hw_offset, 5, "src (%d,%d)\n",
450 data[5] & 0xffff, data[5] >> 16);
451 instr_out(data, hw_offset, 6, "src pitch %d\n",
452 (short)(data[6] & 0xffff));
453 instr_out(data, hw_offset, 7, "src offset 0x%08x\n", data[7]);
457 for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]);
459 if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) {
463 instr_out(data, hw_offset, 0, "%s\n",
464 opcodes_2d[opcode].name);
465 if (opcodes_2d[opcode].max_len > 1) {
466 len = (data[0] & 0x000000ff) + 2;
467 if (len < opcodes_2d[opcode].min_len ||
468 len > opcodes_2d[opcode].max_len) {
469 fprintf(out, "Bad count in %s\n",
470 opcodes_2d[opcode].name);
474 for (i = 1; i < len; i++) {
476 BUFFER_FAIL(count, len,
477 opcodes_2d[opcode].name);
478 instr_out(data, hw_offset, i, "dword %d\n", i);
485 instr_out(data, hw_offset, 0, "2D UNKNOWN\n");
491 decode_3d_1c(uint32_t *data, uint32_t count, uint32_t hw_offset, int *failures)
495 opcode = (data[0] & 0x00f80000) >> 19;
499 instr_out(data, hw_offset, 0,
500 "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n");
503 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_ENABLE %s\n",
504 data[0] & 1 ? "enabled" : "disabled");
507 instr_out(data, hw_offset, 0, "3DSTATE_MAP_COORD_SET_I830\n");
510 instr_out(data, hw_offset, 0, "3DSTATE_MAP_CUBE_I830\n");
513 instr_out(data, hw_offset, 0, "3DSTATE_MAP_TEX_STREAM_I830\n");
517 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n",
523 /** Sets the string dstname to describe the destination of the PS instruction */
525 i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask)
527 uint32_t a0 = data[i];
528 int dst_nr = (a0 >> 14) & 0xf;
533 if (((a0 >> 10) & 0xf) == 0xf) {
536 int dstmask_index = 0;
538 dstmask[dstmask_index++] = '.';
540 dstmask[dstmask_index++] = 'x';
542 dstmask[dstmask_index++] = 'y';
544 dstmask[dstmask_index++] = 'z';
546 dstmask[dstmask_index++] = 'w';
547 dstmask[dstmask_index++] = 0;
559 switch ((a0 >> 19) & 0x7) {
562 fprintf(out, "bad destination reg R%d\n", dst_nr);
563 sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat);
567 fprintf(out, "bad destination reg oC%d\n", dst_nr);
568 sprintf(dstname, "oC%s%s", dstmask, sat);
572 fprintf(out, "bad destination reg oD%d\n", dst_nr);
573 sprintf(dstname, "oD%s%s", dstmask, sat);
577 fprintf(out, "bad destination reg U%d\n", dst_nr);
578 sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat);
581 sprintf(dstname, "RESERVED");
587 i915_get_channel_swizzle(uint32_t select)
589 switch (select & 0x7) {
591 return (select & 8) ? "-x" : "x";
593 return (select & 8) ? "-y" : "y";
595 return (select & 8) ? "-z" : "z";
597 return (select & 8) ? "-w" : "w";
599 return (select & 8) ? "-0" : "0";
601 return (select & 8) ? "-1" : "1";
603 return (select & 8) ? "-bad" : "bad";
608 i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name)
612 sprintf(name, "R%d", src_nr);
614 fprintf(out, "bad src reg %s\n", name);
618 sprintf(name, "T%d", src_nr);
619 else if (src_nr == 8)
620 sprintf(name, "DIFFUSE");
621 else if (src_nr == 9)
622 sprintf(name, "SPECULAR");
623 else if (src_nr == 10)
624 sprintf(name, "FOG");
626 fprintf(out, "bad src reg T%d\n", src_nr);
627 sprintf(name, "RESERVED");
631 sprintf(name, "C%d", src_nr);
633 fprintf(out, "bad src reg %s\n", name);
638 fprintf(out, "bad src reg oC%d\n", src_nr);
643 fprintf(out, "bad src reg oD%d\n", src_nr);
646 sprintf(name, "U%d", src_nr);
648 fprintf(out, "bad src reg %s\n", name);
651 fprintf(out, "bad src reg type %d\n", src_type);
652 sprintf(name, "RESERVED");
657 static void i915_get_instruction_src0(uint32_t *data, int i, char *srcname)
659 uint32_t a0 = data[i];
660 uint32_t a1 = data[i + 1];
661 int src_nr = (a0 >> 2) & 0x1f;
662 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf);
663 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf);
664 const char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf);
665 const char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf);
668 i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname);
669 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
671 if (strcmp(swizzle, ".xyzw") != 0)
672 strcat(srcname, swizzle);
675 static void i915_get_instruction_src1(uint32_t *data, int i, char *srcname)
677 uint32_t a1 = data[i + 1];
678 uint32_t a2 = data[i + 2];
679 int src_nr = (a1 >> 8) & 0x1f;
680 const char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf);
681 const char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf);
682 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf);
683 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf);
686 i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname);
687 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
689 if (strcmp(swizzle, ".xyzw") != 0)
690 strcat(srcname, swizzle);
693 static void i915_get_instruction_src2(uint32_t *data, int i, char *srcname)
695 uint32_t a2 = data[i + 2];
696 int src_nr = (a2 >> 16) & 0x1f;
697 const char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf);
698 const char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf);
699 const char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf);
700 const char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf);
703 i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname);
704 sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z,
706 if (strcmp(swizzle, ".xyzw") != 0)
707 strcat(srcname, swizzle);
711 i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name)
715 sprintf(name, "R%d", src_nr);
717 fprintf(out, "bad src reg %s\n", name);
721 sprintf(name, "T%d", src_nr);
722 else if (src_nr == 8)
723 sprintf(name, "DIFFUSE");
724 else if (src_nr == 9)
725 sprintf(name, "SPECULAR");
726 else if (src_nr == 10)
727 sprintf(name, "FOG");
729 fprintf(out, "bad src reg T%d\n", src_nr);
730 sprintf(name, "RESERVED");
736 fprintf(out, "bad src reg oC%d\n", src_nr);
741 fprintf(out, "bad src reg oD%d\n", src_nr);
744 fprintf(out, "bad src reg type %d\n", src_type);
745 sprintf(name, "RESERVED");
751 i915_decode_alu1(uint32_t *data, uint32_t hw_offset,
752 int i, char *instr_prefix, const char *op_name)
754 char dst[100], src0[100];
756 i915_get_instruction_dst(data, i, dst, 1);
757 i915_get_instruction_src0(data, i, src0);
759 instr_out(data, hw_offset, i++, "%s: %s %s, %s\n", instr_prefix,
761 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
762 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
766 i915_decode_alu2(uint32_t *data, uint32_t hw_offset,
767 int i, char *instr_prefix, const char *op_name)
769 char dst[100], src0[100], src1[100];
771 i915_get_instruction_dst(data, i, dst, 1);
772 i915_get_instruction_src0(data, i, src0);
773 i915_get_instruction_src1(data, i, src1);
775 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s\n", instr_prefix,
776 op_name, dst, src0, src1);
777 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
778 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
782 i915_decode_alu3(uint32_t *data, uint32_t hw_offset,
783 int i, char *instr_prefix, const char *op_name)
785 char dst[100], src0[100], src1[100], src2[100];
787 i915_get_instruction_dst(data, i, dst, 1);
788 i915_get_instruction_src0(data, i, src0);
789 i915_get_instruction_src1(data, i, src1);
790 i915_get_instruction_src2(data, i, src2);
792 instr_out(data, hw_offset, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix,
793 op_name, dst, src0, src1, src2);
794 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
795 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
799 i915_decode_tex(uint32_t *data, uint32_t hw_offset, int i,
800 const char *instr_prefix, const char *tex_name)
802 uint32_t t0 = data[i];
803 uint32_t t1 = data[i + 1];
808 i915_get_instruction_dst(data, i, dst_name, 0);
809 i915_get_instruction_addr((t1 >> 24) & 0x7,
810 (t1 >> 17) & 0xf, addr_name);
811 sampler_nr = t0 & 0xf;
813 instr_out(data, hw_offset, i++, "%s: %s %s, S%d, %s\n", instr_prefix,
814 tex_name, dst_name, sampler_nr, addr_name);
815 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
816 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
820 i915_decode_dcl(uint32_t *data, uint32_t hw_offset, int i, char *instr_prefix)
822 uint32_t d0 = data[i];
823 const char *sampletype;
824 int dcl_nr = (d0 >> 14) & 0xf;
825 const char *dcl_x = d0 & (1 << 10) ? "x" : "";
826 const char *dcl_y = d0 & (1 << 11) ? "y" : "";
827 const char *dcl_z = d0 & (1 << 12) ? "z" : "";
828 const char *dcl_w = d0 & (1 << 13) ? "w" : "";
831 switch ((d0 >> 19) & 0x3) {
833 sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w);
834 if (strcmp(dcl_mask, ".") == 0)
835 fprintf(out, "bad (empty) dcl mask\n");
838 fprintf(out, "bad T%d dcl register number\n", dcl_nr);
840 if (strcmp(dcl_mask, ".x") != 0 &&
841 strcmp(dcl_mask, ".xy") != 0 &&
842 strcmp(dcl_mask, ".xz") != 0 &&
843 strcmp(dcl_mask, ".w") != 0 &&
844 strcmp(dcl_mask, ".xyzw") != 0) {
845 fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr,
848 instr_out(data, hw_offset, i++, "%s: DCL T%d%s\n",
849 instr_prefix, dcl_nr, dcl_mask);
851 if (strcmp(dcl_mask, ".xz") == 0)
852 fprintf(out, "errataed bad dcl mask %s\n",
854 else if (strcmp(dcl_mask, ".xw") == 0)
855 fprintf(out, "errataed bad dcl mask %s\n",
857 else if (strcmp(dcl_mask, ".xzw") == 0)
858 fprintf(out, "errataed bad dcl mask %s\n",
862 instr_out(data, hw_offset, i++,
863 "%s: DCL DIFFUSE%s\n", instr_prefix,
865 } else if (dcl_nr == 9) {
866 instr_out(data, hw_offset, i++,
867 "%s: DCL SPECULAR%s\n", instr_prefix,
869 } else if (dcl_nr == 10) {
870 instr_out(data, hw_offset, i++,
871 "%s: DCL FOG%s\n", instr_prefix,
875 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
876 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
879 switch ((d0 >> 22) & 0x3) {
890 sampletype = "RESERVED";
894 fprintf(out, "bad S%d dcl register number\n", dcl_nr);
895 instr_out(data, hw_offset, i++, "%s: DCL S%d %s\n",
896 instr_prefix, dcl_nr, sampletype);
897 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
898 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
901 instr_out(data, hw_offset, i++, "%s: DCL RESERVED%d\n",
902 instr_prefix, dcl_nr);
903 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
904 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
909 i915_decode_instruction(uint32_t *data, uint32_t hw_offset,
910 int i, char *instr_prefix)
912 switch ((data[i] >> 24) & 0x1f) {
914 instr_out(data, hw_offset, i++, "%s: NOP\n", instr_prefix);
915 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
916 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
919 i915_decode_alu2(data, hw_offset, i, instr_prefix, "ADD");
922 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOV");
925 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MUL");
928 i915_decode_alu3(data, hw_offset, i, instr_prefix, "MAD");
931 i915_decode_alu3(data, hw_offset, i, instr_prefix, "DP2ADD");
934 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP3");
937 i915_decode_alu2(data, hw_offset, i, instr_prefix, "DP4");
940 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FRC");
943 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RCP");
946 i915_decode_alu1(data, hw_offset, i, instr_prefix, "RSQ");
949 i915_decode_alu1(data, hw_offset, i, instr_prefix, "EXP");
952 i915_decode_alu1(data, hw_offset, i, instr_prefix, "LOG");
955 i915_decode_alu2(data, hw_offset, i, instr_prefix, "CMP");
958 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MIN");
961 i915_decode_alu2(data, hw_offset, i, instr_prefix, "MAX");
964 i915_decode_alu1(data, hw_offset, i, instr_prefix, "FLR");
967 i915_decode_alu1(data, hw_offset, i, instr_prefix, "MOD");
970 i915_decode_alu1(data, hw_offset, i, instr_prefix, "TRC");
973 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SGE");
976 i915_decode_alu2(data, hw_offset, i, instr_prefix, "SLT");
979 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLD");
982 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDP");
985 i915_decode_tex(data, hw_offset, i, instr_prefix, "TEXLDB");
988 i915_decode_dcl(data, hw_offset, i, instr_prefix);
991 instr_out(data, hw_offset, i++, "%s: unknown\n", instr_prefix);
992 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
993 instr_out(data, hw_offset, i++, "%s\n", instr_prefix);
999 decode_compare_func(uint32_t op)
1023 decode_stencil_op(uint32_t op)
1047 decode_logic_op(uint32_t op)
1087 decode_blend_fact(uint32_t op)
1097 return "inv_src_colr";
1101 return "inv_src_alpha";
1105 return "inv_dst_alpha";
1109 return "inv_dst_colr";
1111 return "src_alpha_sat";
1115 return "inv_cnst_colr";
1117 return "cnst_alpha";
1119 return "inv_const_alpha";
1125 decode_tex_coord_mode(uint32_t mode)
1127 switch (mode & 0x7) {
1133 return "clamp_edge";
1137 return "clamp_border";
1139 return "mirror_once";
1145 decode_sample_filter(uint32_t mode)
1147 switch (mode & 0x7) {
1153 return "anisotropic";
1167 decode_3d_1d(uint32_t *data, uint32_t count,
1168 uint32_t hw_offset, uint32_t devid, int *failures)
1170 unsigned int len, i, c, idx, word, map, sampler, instr;
1171 const char *format, *zformat, *type;
1177 unsigned int min_len;
1178 unsigned int max_len;
1180 } opcodes_3d_1d[] = {
1181 { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" },
1182 { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" },
1183 { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" },
1184 { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" },
1185 { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" },
1186 { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" },
1187 { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" },
1188 { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" },
1189 { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" },
1190 { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" },
1191 { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" },
1192 { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" },
1193 { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" },
1194 { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" },
1195 { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" },
1196 { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830"},
1199 opcode = (data[0] & 0x00ff0000) >> 16;
1203 /* This instruction is unusual. A 0 length means just
1204 * 1 DWORD instead of 2. The 0 length is specified in
1205 * one place to be unsupported, but stated to be
1206 * required in another, and 0 length LOAD_INDIRECTs
1207 * appear to cause no harm at least.
1209 instr_out(data, hw_offset, 0, "3DSTATE_LOAD_INDIRECT\n");
1210 len = (data[0] & 0x000000ff) + 1;
1212 if (data[0] & (0x01 << 8)) {
1214 BUFFER_FAIL(count, len,
1215 "3DSTATE_LOAD_INDIRECT");
1216 instr_out(data, hw_offset, i++, "SIS.0\n");
1217 instr_out(data, hw_offset, i++, "SIS.1\n");
1219 if (data[0] & (0x02 << 8)) {
1221 BUFFER_FAIL(count, len,
1222 "3DSTATE_LOAD_INDIRECT");
1223 instr_out(data, hw_offset, i++, "DIS.0\n");
1225 if (data[0] & (0x04 << 8)) {
1227 BUFFER_FAIL(count, len,
1228 "3DSTATE_LOAD_INDIRECT");
1229 instr_out(data, hw_offset, i++, "SSB.0\n");
1230 instr_out(data, hw_offset, i++, "SSB.1\n");
1232 if (data[0] & (0x08 << 8)) {
1234 BUFFER_FAIL(count, len,
1235 "3DSTATE_LOAD_INDIRECT");
1236 instr_out(data, hw_offset, i++, "MSB.0\n");
1237 instr_out(data, hw_offset, i++, "MSB.1\n");
1239 if (data[0] & (0x10 << 8)) {
1241 BUFFER_FAIL(count, len,
1242 "3DSTATE_LOAD_INDIRECT");
1243 instr_out(data, hw_offset, i++, "PSP.0\n");
1244 instr_out(data, hw_offset, i++, "PSP.1\n");
1246 if (data[0] & (0x20 << 8)) {
1248 BUFFER_FAIL(count, len,
1249 "3DSTATE_LOAD_INDIRECT");
1250 instr_out(data, hw_offset, i++, "PSC.0\n");
1251 instr_out(data, hw_offset, i++, "PSC.1\n");
1254 fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n");
1260 instr_out(data, hw_offset, 0,
1261 "3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1262 len = (data[0] & 0x0000000f) + 2;
1264 for (word = 0; word <= 8; word++) {
1265 if (data[0] & (1 << (4 + word))) {
1267 BUFFER_FAIL(count, len,
1268 "3DSTATE_LOAD_STATE_IMMEDIATE_1");
1270 /* save vertex state for decode */
1271 if (!IS_GEN2(devid)) {
1283 instr_out(data, hw_offset, i,
1284 "S0: vbo offset: 0x%08x%s\n",
1287 ", auto cache invalidate disabled"
1291 instr_out(data, hw_offset, i,
1292 "S1: vertex width: %i, vertex pitch: %i\n",
1299 instr_out(data, hw_offset, i,
1300 "S2: texcoord formats: ");
1301 for (int tex_num = 0;
1302 tex_num < 8; tex_num++) {
1347 instr_out(data, hw_offset, i,
1348 "S3: not documented\n",
1353 const char *cullmode = "";
1354 const char *vfmt_xyzw = "";
1355 switch ((data[i] >> 13)
1392 case 1 << 6 | 1 << 2:
1396 case 2 << 6 | 1 << 2:
1400 case 3 << 6 | 1 << 2:
1404 case 4 << 6 | 1 << 2:
1411 "S4: point_width=%i, line_width=%.1f,"
1412 "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s "
1475 "force default diffuse, "
1481 "force default specular, "
1487 "local depth ofs enable, "
1493 "point sprite enable, "
1508 "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, "
1509 "stencil_fail=%s, stencil_pass_z_fail=%s, "
1510 "stencil_pass_z_pass=%s, %s%s%s%s\n",
1540 " force default point size,"
1546 " last pixel enable,"
1552 " global depth ofs enable,"
1578 "stencil write enable, "
1584 "stencil test enable, "
1590 "color dither enable, "
1601 instr_out(data, hw_offset, i,
1602 "S6: %salpha_test=%s, alpha_ref=0x%x, "
1603 "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, "
1604 "%s%stristrip_provoking_vertex=%i\n",
1605 data[i] & (1 << 31) ?
1606 "alpha test enable, "
1614 data[i] & (1 << 15) ?
1615 "cbuf blend enable, "
1617 decode_blend_fact(data
1621 decode_blend_fact(data
1625 data[i] & (1 << 3) ?
1626 "depth write enable, "
1628 data[i] & (1 << 2) ?
1629 "cbuf write enable, "
1634 instr_out(data, hw_offset, i,
1635 "S7: depth offset constant: 0x%08x\n",
1640 instr_out(data, hw_offset, i,
1641 "S%d: 0x%08x\n", i, data[i]);
1648 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1653 instr_out(data, hw_offset, 0,
1654 "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1655 len = (data[0] & 0x0000000f) + 2;
1657 for (word = 6; word <= 14; word++) {
1658 if (data[0] & (1 << word)) {
1660 BUFFER_FAIL(count, len,
1661 "3DSTATE_LOAD_STATE_IMMEDIATE_2");
1664 instr_out(data, hw_offset, i++,
1666 else if (word >= 7 && word <= 10) {
1667 instr_out(data, hw_offset, i++,
1668 "TB%dC\n", word - 7);
1669 instr_out(data, hw_offset, i++,
1670 "TB%dA\n", word - 7);
1671 } else if (word >= 11 && word <= 14) {
1672 instr_out(data, hw_offset, i,
1673 "TM%dS0: offset=0x%08x, %s\n",
1675 data[i] & 0xfffffffe,
1676 data[i] & 1 ? "use fence" :
1679 instr_out(data, hw_offset, i,
1680 "TM%dS1: height=%i, width=%i, %s\n",
1681 word - 11, data[i] >> 21,
1682 (data[i] >> 10) & 0x3ff,
1683 data[i] & 2 ? (data[i] & 1 ?
1688 instr_out(data, hw_offset, i,
1689 "TM%dS2: pitch=%i, \n",
1691 ((data[i] >> 21) + 1) * 4);
1693 instr_out(data, hw_offset, i++,
1694 "TM%dS3\n", word - 11);
1695 instr_out(data, hw_offset, i++,
1696 "TM%dS4: dflt color\n",
1703 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1708 instr_out(data, hw_offset, 0, "3DSTATE_MAP_STATE\n");
1709 len = (data[0] & 0x0000003f) + 2;
1710 instr_out(data, hw_offset, 1, "mask\n");
1713 for (map = 0; map <= 15; map++) {
1714 if (data[1] & (1 << map)) {
1715 int width, height, pitch, dword;
1719 BUFFER_FAIL(count, len,
1720 "3DSTATE_MAP_STATE");
1723 instr_out(data, hw_offset, i++,
1724 "map %d MS2 %s%s%s\n", map,
1726 "untrusted surface, " : "",
1728 "vertical line stride enable, " : "",
1730 "vertical ofs enable, " : "");
1733 width = ((dword >> 10) & ((1 << 11) - 1)) + 1;
1734 height = ((dword >> 21) & ((1 << 11) - 1)) + 1;
1737 if (dword & (1 << 2))
1739 else if (dword & (1 << 1))
1740 tiling = dword & (1 << 0) ? "Y" : "X";
1743 switch ((dword >> 7) & 0x7) {
1746 switch ((dword >> 3) & 0xf) {
1763 switch ((dword >> 3) & 0xf) {
1768 format = " argb1555";
1771 format = " argb4444";
1777 format = " bump655";
1792 switch ((dword >> 3) & 0xf) {
1794 format = " argb8888";
1797 format = " abgr8888";
1800 format = " xrgb8888";
1803 format = " xbgr8888";
1806 format = " qwvu8888";
1809 format = " axvu8888";
1812 format = " lxvu8888";
1815 format = " xlvu8888";
1818 format = " argb2101010";
1821 format = " abgr2101010";
1824 format = " awvu2101010";
1845 switch ((dword >> 3) & 0xf) {
1847 format = " yuv_swapy";
1853 format = " yuv_swapuv";
1856 format = " yuv_swapuvy";
1861 type = "compressed";
1862 switch ((dword >> 3) & 0x7) {
1876 format = " dxt1_rb";
1881 type = "4b indexed";
1882 switch ((dword >> 3) & 0xf) {
1884 format = " argb8888";
1890 instr_out(data, hw_offset, i++,
1891 "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n",
1892 map, width, height, type, format,
1894 dword & (1 << 9) ? " palette select" :
1899 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1);
1900 instr_out(data, hw_offset, i++,
1901 "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n",
1902 map, pitch, (dword >> 9) & 0x3f,
1903 dword & 0xff, (dword >> 15) & 0x3f,
1904 dword & (1 << 8) ? "miplayout legacy"
1905 : "miplayout right");
1909 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
1915 instr_out(data, hw_offset, 0,
1916 "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1917 len = (data[0] & 0x000000ff) + 2;
1920 for (c = 0; c <= 31; c++) {
1921 if (data[1] & (1 << c)) {
1923 BUFFER_FAIL(count, len,
1924 "3DSTATE_PIXEL_SHADER_CONSTANTS");
1925 instr_out(data, hw_offset, i, "C%d.X = %f\n", c,
1926 int_as_float(data[i]));
1928 instr_out(data, hw_offset, i, "C%d.Y = %f\n",
1929 c, int_as_float(data[i]));
1931 instr_out(data, hw_offset, i, "C%d.Z = %f\n",
1932 c, int_as_float(data[i]));
1934 instr_out(data, hw_offset, i, "C%d.W = %f\n",
1935 c, int_as_float(data[i]));
1941 "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1946 instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
1947 len = (data[0] & 0x000000ff) + 2;
1948 if ((len - 1) % 3 != 0 || len > 370) {
1950 "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
1954 for (instr = 0; instr < (len - 1) / 3; instr++) {
1955 char instr_prefix[10];
1958 BUFFER_FAIL(count, len,
1959 "3DSTATE_PIXEL_SHADER_PROGRAM");
1960 sprintf(instr_prefix, "PS%03d", instr);
1961 i915_decode_instruction(data, hw_offset, i,
1969 instr_out(data, hw_offset, 0, "3DSTATE_SAMPLER_STATE\n");
1970 instr_out(data, hw_offset, 1, "mask\n");
1971 len = (data[0] & 0x0000003f) + 2;
1973 for (sampler = 0; sampler <= 15; sampler++) {
1974 if (data[1] & (1 << sampler)) {
1976 const char *mip_filter = "";
1978 BUFFER_FAIL(count, len,
1979 "3DSTATE_SAMPLER_STATE");
1981 switch ((dword >> 20) & 0x3) {
1983 mip_filter = "none";
1986 mip_filter = "nearest";
1989 mip_filter = "linear";
1992 instr_out(data, hw_offset, i++,
1993 "sampler %d SS2:%s%s%s "
1994 "base_mip_level=%i, mip_filter=%s, mag_filter=%s, min_filter=%s "
1995 "lod_bias=%.2f,%s max_aniso=%i, shadow_func=%s\n",
1997 dword & (1 << 31) ? " reverse gamma,"
1999 dword & (1 << 30) ? " packed2planar,"
2002 " colorspace conversion," : "",
2003 (dword >> 22) & 0x1f, mip_filter,
2004 decode_sample_filter(dword >> 17),
2005 decode_sample_filter(dword >> 14),
2006 ((dword >> 5) & 0x1ff) / (0x10 * 1.0),
2007 dword & (1 << 4) ? " shadow," : "",
2008 dword & (1 << 3) ? 4 : 2,
2009 decode_compare_func(dword));
2011 instr_out(data, hw_offset, i++,
2012 "sampler %d SS3: min_lod=%.2f,%s "
2013 "tcmode_x=%s, tcmode_y=%s, tcmode_z=%s,%s texmap_idx=%i,%s\n",
2015 ((dword >> 24) & 0xff) / (0x10 * 1.0),
2017 " kill pixel enable," : "",
2018 decode_tex_coord_mode(dword >> 12),
2019 decode_tex_coord_mode(dword >> 9),
2020 decode_tex_coord_mode(dword >> 6),
2022 " normalized coords," : "",
2024 dword & (1 << 0) ? " deinterlacer," :
2027 instr_out(data, hw_offset, i++,
2028 "sampler %d SS4: border color\n",
2030 ((dword >> 24) & 0xff) / (0x10 * 1.0),
2035 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
2040 len = (data[0] & 0x0000000f) + 2;
2044 "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
2046 BUFFER_FAIL(count, len,
2047 "3DSTATE_DEST_BUFFER_VARIABLES");
2049 instr_out(data, hw_offset, 0,
2050 "3DSTATE_DEST_BUFFER_VARIABLES\n");
2052 switch ((data[1] >> 8) & 0xf) {
2057 format = "x1r5g5b5";
2063 format = "a8r8g8b8";
2066 format = "ycrcb_swapy";
2069 format = "ycrcb_normal";
2072 format = "ycrcb_swapuv";
2075 format = "ycrcb_swapuvy";
2078 format = "a4r4g4b4";
2081 format = "a1r5g5b5";
2084 format = "a2r10g10b10";
2090 switch ((data[1] >> 2) & 0x3) {
2104 instr_out(data, hw_offset, 1,
2105 "%s format, %s depth format, early Z %sabled\n",
2107 (data[1] & (1 << 31)) ? "en" : "dis");
2112 const char *name, *tiling;
2114 len = (data[0] & 0x0000000f) + 2;
2117 "Bad count in 3DSTATE_BUFFER_INFO\n");
2119 BUFFER_FAIL(count, len, "3DSTATE_BUFFER_INFO");
2121 switch ((data[1] >> 24) & 0x7) {
2134 if (data[1] & (1 << 23))
2136 else if (data[1] & (1 << 22))
2137 tiling = data[1] & (1 << 21) ? "Y" : "X";
2139 instr_out(data, hw_offset, 0, "3DSTATE_BUFFER_INFO\n");
2140 instr_out(data, hw_offset, 1,
2141 "%s, tiling = %s, pitch=%d\n", name, tiling,
2144 instr_out(data, hw_offset, 2, "address\n");
2148 len = (data[0] & 0x0000000f) + 2;
2152 "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n");
2154 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_RECTANGLE");
2156 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_RECTANGLE\n");
2157 instr_out(data, hw_offset, 1, "(%d,%d)\n",
2158 data[1] & 0xffff, data[1] >> 16);
2159 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2160 data[2] & 0xffff, data[2] >> 16);
2164 len = (data[0] & 0x0000000f) + 2;
2168 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2170 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
2172 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
2173 instr_out(data, hw_offset, 1, "%s\n",
2174 data[1] & (1 << 30) ? "depth ofs disabled " : "");
2175 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2176 data[2] & 0xffff, data[2] >> 16);
2177 instr_out(data, hw_offset, 3, "(%d,%d)\n",
2178 data[3] & 0xffff, data[3] >> 16);
2179 instr_out(data, hw_offset, 4, "(%d,%d)\n",
2180 data[4] & 0xffff, data[4] >> 16);
2184 len = (data[0] & 0x0000000f) + 2;
2187 fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n");
2189 BUFFER_FAIL(count, len, "3DSTATE_CLEAR_PARAMETERS");
2191 instr_out(data, hw_offset, 0, "3DSTATE_CLEAR_PARAMETERS\n");
2192 instr_out(data, hw_offset, 1, "prim_type=%s, clear=%s%s%s\n",
2193 data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT",
2194 data[1] & (1 << 2) ? "color," : "",
2195 data[1] & (1 << 1) ? "depth," : "",
2196 data[1] & (1 << 0) ? "stencil," : "");
2197 instr_out(data, hw_offset, 2, "clear color\n");
2198 instr_out(data, hw_offset, 3, "clear depth/stencil\n");
2199 instr_out(data, hw_offset, 4, "color value (rgba8888)\n");
2200 instr_out(data, hw_offset, 5, "depth value %f\n",
2201 int_as_float(data[5]));
2202 instr_out(data, hw_offset, 6, "clear stencil\n");
2206 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) {
2207 opcode_3d_1d = &opcodes_3d_1d[idx];
2208 if (opcode_3d_1d->i830_only && !IS_GEN2(devid))
2211 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
2214 instr_out(data, hw_offset, 0, "%s\n",
2215 opcode_3d_1d->name);
2216 if (opcode_3d_1d->max_len > 1) {
2217 len = (data[0] & 0x0000ffff) + 2;
2218 if (len < opcode_3d_1d->min_len ||
2219 len > opcode_3d_1d->max_len) {
2220 fprintf(out, "Bad count in %s\n",
2221 opcode_3d_1d->name);
2226 for (i = 1; i < len; i++) {
2228 BUFFER_FAIL(count, len,
2229 opcode_3d_1d->name);
2230 instr_out(data, hw_offset, i, "dword %d\n", i);
2237 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n",
2244 decode_3d_primitive(uint32_t *data, uint32_t count, uint32_t hw_offset,
2247 char immediate = (data[0] & (1 << 23)) == 0;
2248 unsigned int len, i, j, ret;
2249 const char *primtype;
2250 int original_s2 = saved_s2;
2251 int original_s4 = saved_s4;
2253 switch ((data[0] >> 18) & 0xf) {
2255 primtype = "TRILIST";
2258 primtype = "TRISTRIP";
2261 primtype = "TRISTRIP_REVERSE";
2264 primtype = "TRIFAN";
2267 primtype = "POLYGON";
2270 primtype = "LINELIST";
2273 primtype = "LINESTRIP";
2276 primtype = "RECTLIST";
2279 primtype = "POINTLIST";
2285 primtype = "CLEAR_RECT";
2290 primtype = "unknown";
2294 /* XXX: 3DPRIM_DIB not supported */
2296 len = (data[0] & 0x0003ffff) + 2;
2297 instr_out(data, hw_offset, 0, "3DPRIMITIVE inline %s\n",
2300 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
2301 if (!saved_s2_set || !saved_s4_set) {
2302 fprintf(out, "unknown vertex format\n");
2303 for (i = 1; i < len; i++) {
2304 instr_out(data, hw_offset, i,
2305 " vertex data (%f float)\n",
2306 int_as_float(data[i]));
2309 unsigned int vertex = 0;
2310 for (i = 1; i < len;) {
2313 #define VERTEX_OUT(fmt, ...) do { \
2315 instr_out(data, hw_offset, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
2317 fprintf(out, " missing data in V%d\n", vertex); \
2321 VERTEX_OUT("X = %f", int_as_float(data[i]));
2322 VERTEX_OUT("Y = %f", int_as_float(data[i]));
2323 switch (saved_s4 >> 6 & 0x7) {
2325 VERTEX_OUT("Z = %f",
2326 int_as_float(data[i]));
2329 VERTEX_OUT("Z = %f",
2330 int_as_float(data[i]));
2331 VERTEX_OUT("W = %f",
2332 int_as_float(data[i]));
2337 VERTEX_OUT("W = %f",
2338 int_as_float(data[i]));
2341 fprintf(out, "bad S4 position mask\n");
2344 if (saved_s4 & (1 << 10)) {
2346 ("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
2347 "B=0x%02x)", data[i] >> 24,
2348 (data[i] >> 16) & 0xff,
2349 (data[i] >> 8) & 0xff,
2352 if (saved_s4 & (1 << 11)) {
2354 ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
2355 "B=0x%02x)", data[i] >> 24,
2356 (data[i] >> 16) & 0xff,
2357 (data[i] >> 8) & 0xff,
2360 if (saved_s4 & (1 << 12))
2361 VERTEX_OUT("width = 0x%08x)", data[i]);
2363 for (tc = 0; tc <= 7; tc++) {
2364 switch ((saved_s2 >> (tc * 4)) & 0xf) {
2366 VERTEX_OUT("T%d.X = %f", tc,
2369 VERTEX_OUT("T%d.Y = %f", tc,
2374 VERTEX_OUT("T%d.X = %f", tc,
2377 VERTEX_OUT("T%d.Y = %f", tc,
2380 VERTEX_OUT("T%d.Z = %f", tc,
2385 VERTEX_OUT("T%d.X = %f", tc,
2388 VERTEX_OUT("T%d.Y = %f", tc,
2391 VERTEX_OUT("T%d.Z = %f", tc,
2394 VERTEX_OUT("T%d.W = %f", tc,
2399 VERTEX_OUT("T%d.X = %f", tc,
2405 ("T%d.XY = 0x%08x half-float",
2410 ("T%d.XY = 0x%08x half-float",
2413 ("T%d.ZW = 0x%08x half-float",
2420 "bad S2.T%d format\n",
2430 /* indirect vertices */
2431 len = data[0] & 0x0000ffff; /* index count */
2432 if (data[0] & (1 << 17)) {
2433 /* random vertex access */
2434 if (count < (len + 1) / 2 + 1) {
2435 BUFFER_FAIL(count, (len + 1) / 2 + 1,
2436 "3DPRIMITIVE random indirect");
2438 instr_out(data, hw_offset, 0,
2439 "3DPRIMITIVE random indirect %s (%d)\n",
2442 /* vertex indices continue until 0xffff is
2445 for (i = 1; i < count; i++) {
2446 if ((data[i] & 0xffff) == 0xffff) {
2447 instr_out(data, hw_offset, i,
2448 " indices: (terminator)\n");
2451 } else if ((data[i] >> 16) == 0xffff) {
2452 instr_out(data, hw_offset, i,
2453 " indices: 0x%04x, (terminator)\n",
2458 instr_out(data, hw_offset, i,
2459 " indices: 0x%04x, 0x%04x\n",
2465 "3DPRIMITIVE: no terminator found in index buffer\n");
2470 /* fixed size vertex index buffer */
2471 for (j = 1, i = 0; i < len; i += 2, j++) {
2472 if (i * 2 == len - 1) {
2473 instr_out(data, hw_offset, j,
2474 " indices: 0x%04x\n",
2477 instr_out(data, hw_offset, j,
2478 " indices: 0x%04x, 0x%04x\n",
2484 ret = (len + 1) / 2 + 1;
2487 /* sequential vertex access */
2489 BUFFER_FAIL(count, 2,
2490 "3DPRIMITIVE seq indirect");
2491 instr_out(data, hw_offset, 0,
2492 "3DPRIMITIVE sequential indirect %s, %d starting from "
2493 "%d\n", primtype, len, data[1] & 0xffff);
2494 instr_out(data, hw_offset, 1, " start\n");
2501 saved_s2 = original_s2;
2502 saved_s4 = original_s4;
2507 decode_3d(uint32_t *data, uint32_t count, uint32_t hw_offset, uint32_t devid,
2515 unsigned int min_len;
2516 unsigned int max_len;
2519 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
2520 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
2521 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
2522 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
2523 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
2524 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
2525 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
2526 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
2527 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES"},
2530 opcode = (data[0] & 0x1f000000) >> 24;
2534 return decode_3d_primitive(data, count, hw_offset, failures);
2536 return decode_3d_1d(data, count, hw_offset, devid, failures);
2538 return decode_3d_1c(data, count, hw_offset, failures);
2541 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2542 opcode_3d = &opcodes_3d[idx];
2543 if (opcode == opcode_3d->opcode) {
2544 unsigned int len = 1, i;
2546 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
2547 if (opcode_3d->max_len > 1) {
2548 len = (data[0] & 0xff) + 2;
2549 if (len < opcode_3d->min_len ||
2550 len > opcode_3d->max_len) {
2551 fprintf(out, "Bad count in %s\n",
2556 for (i = 1; i < len; i++) {
2558 BUFFER_FAIL(count, len,
2560 instr_out(data, hw_offset, i, "dword %d\n", i);
2566 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode);
2571 static const char *get_965_surfacetype(unsigned int surfacetype)
2573 switch (surfacetype) {
2591 static const char *get_965_depthformat(unsigned int depthformat)
2593 switch (depthformat) {
2595 return "s8_z24float";
2607 static const char *get_965_element_component(uint32_t data, int component)
2609 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
2611 switch (component_control) {
2615 switch (component) {
2640 static const char *get_965_prim_type(uint32_t data)
2642 uint32_t primtype = (data >> 10) & 0x1f;
2646 return "point list";
2650 return "line strip";
2660 return "quad strip";
2662 return "line list adj";
2664 return "line strip adj";
2666 return "tri list adj";
2668 return "tri strip adj";
2670 return "tri strip reverse";
2678 return "point list bf";
2680 return "line strip cont";
2682 return "line strip bf";
2684 return "line strip cont bf";
2686 return "tri fan no stipple";
2693 i965_decode_urb_fence(uint32_t *data, uint32_t hw_offset, int len, uint32_t count,
2696 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
2699 fprintf(out, "Bad count in URB_FENCE\n");
2701 BUFFER_FAIL(count, len, "URB_FENCE");
2703 vs_fence = data[1] & 0x3ff;
2704 gs_fence = (data[1] >> 10) & 0x3ff;
2705 clip_fence = (data[1] >> 20) & 0x3ff;
2706 sf_fence = data[2] & 0x3ff;
2707 vfe_fence = (data[2] >> 10) & 0x3ff;
2708 cs_fence = (data[2] >> 20) & 0x7ff;
2710 instr_out(data, hw_offset, 0, "URB_FENCE: %s%s%s%s%s%s\n",
2711 (data[0] >> 13) & 1 ? "cs " : "",
2712 (data[0] >> 12) & 1 ? "vfe " : "",
2713 (data[0] >> 11) & 1 ? "sf " : "",
2714 (data[0] >> 10) & 1 ? "clip " : "",
2715 (data[0] >> 9) & 1 ? "gs " : "",
2716 (data[0] >> 8) & 1 ? "vs " : "");
2717 instr_out(data, hw_offset, 1,
2718 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
2719 vs_fence, clip_fence, gs_fence);
2720 instr_out(data, hw_offset, 2,
2721 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
2722 sf_fence, vfe_fence, cs_fence);
2723 if (gs_fence < vs_fence)
2724 fprintf(out, "gs fence < vs fence!\n");
2725 if (clip_fence < gs_fence)
2726 fprintf(out, "clip fence < gs fence!\n");
2727 if (sf_fence < clip_fence)
2728 fprintf(out, "sf fence < clip fence!\n");
2729 if (cs_fence < sf_fence)
2730 fprintf(out, "cs fence < sf fence!\n");
2736 state_base_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2739 if (data[index] & 1) {
2740 instr_out(data, hw_offset, index,
2741 "%s state base address 0x%08x\n", name,
2744 instr_out(data, hw_offset, index, "%s state base not updated\n",
2750 state_max_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2753 if (data[index] & 1) {
2754 if (data[index] == 1) {
2755 instr_out(data, hw_offset, index,
2756 "%s state upper bound disabled\n", name);
2758 instr_out(data, hw_offset, index,
2759 "%s state upper bound 0x%08x\n", name,
2763 instr_out(data, hw_offset, index,
2764 "%s state upper bound not updated\n", name);
2769 decode_3d_965(uint32_t *data, uint32_t count, uint32_t hw_offset, uint32_t devid,
2773 unsigned int idx, len;
2774 unsigned int i, sba_len;
2775 const char *desc1 = NULL;
2779 int unsigned min_len;
2780 int unsigned max_len;
2783 { 0x6000, 3, 3, "URB_FENCE" },
2784 { 0x6001, 2, 2, "CS_URB_STATE" },
2785 { 0x6002, 2, 2, "CONSTANT_BUFFER" },
2786 { 0x6101, 6, 6, "STATE_BASE_ADDRESS" },
2787 { 0x6102, 2, 2, "STATE_SIP" },
2788 { 0x6104, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2789 { 0x680b, 1, 1, "3DSTATE_VF_STATISTICS" },
2790 { 0x6904, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2791 { 0x7800, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
2792 { 0x7801, 6, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
2793 { 0x7808, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
2794 { 0x7809, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
2795 { 0x780a, 3, 3, "3DSTATE_INDEX_BUFFER" },
2796 { 0x780b, 1, 1, "3DSTATE_VF_STATISTICS" },
2797 { 0x7900, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
2798 { 0x7901, 5, 5, "3DSTATE_CONSTANT_COLOR" },
2799 { 0x7905, 5, 7, "3DSTATE_DEPTH_BUFFER" },
2800 { 0x7906, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
2801 { 0x7907, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
2802 { 0x7908, 3, 3, "3DSTATE_LINE_STIPPLE" },
2803 { 0x7909, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
2804 { 0x7909, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2805 { 0x790a, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
2806 { 0x790b, 4, 4, "3DSTATE_GS_SVB_INDEX" },
2807 { 0x790d, 3, 3, "3DSTATE_MULTISAMPLE" },
2808 { 0x7910, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2809 { 0x7b00, 6, 6, "3DPRIMITIVE" },
2810 { 0x7802, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
2811 { 0x7805, 3, 3, "3DSTATE_URB" },
2812 { 0x780d, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
2813 { 0x780e, 4, 4, "3DSTATE_CC_STATE_POINTERS" },
2814 { 0x780f, 2, 2, "3DSTATE_SCISSOR_STATE_POINTERS" },
2815 { 0x7810, 6, 6, "3DSTATE_VS_STATE" },
2816 { 0x7811, 7, 7, "3DSTATE_GS_STATE" },
2817 { 0x7812, 4, 4, "3DSTATE_CLIP_STATE" },
2818 { 0x7813, 20, 20, "3DSTATE_SF_STATE" },
2819 { 0x7814, 9, 9, "3DSTATE_WM_STATE" },
2820 { 0x7815, 5, 5, "3DSTATE_CONSTANT_VS_STATE" },
2821 { 0x7816, 5, 5, "3DSTATE_CONSTANT_GS_STATE" },
2822 { 0x7817, 5, 5, "3DSTATE_CONSTANT_PS_STATE" },
2823 { 0x7818, 2, 2, "3DSTATE_SAMPLE_MASK"},
2826 len = (data[0] & 0x0000ffff) + 2;
2828 opcode = (data[0] & 0xffff0000) >> 16;
2831 len = (data[0] & 0x000000ff) + 2;
2832 return i965_decode_urb_fence(data, hw_offset, len, count,
2835 instr_out(data, hw_offset, 0, "CS_URB_STATE\n");
2836 instr_out(data, hw_offset, 1,
2837 "entry_size: %d [%d bytes], n_entries: %d\n",
2838 (data[1] >> 4) & 0x1f,
2839 (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7);
2842 len = (data[0] & 0x000000ff) + 2;
2843 instr_out(data, hw_offset, 0, "CONSTANT_BUFFER: %s\n",
2844 (data[0] >> 8) & 1 ? "valid" : "invalid");
2845 instr_out(data, hw_offset, 1,
2846 "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f,
2847 ((data[1] & 0x3f) + 1) * 64);
2851 instr_out(data, hw_offset, 0, "STATE_BASE_ADDRESS\n");
2854 if (IS_GEN6(devid) || IS_GEN7(devid))
2856 else if (IS_GEN5(devid))
2861 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
2863 BUFFER_FAIL(count, len, "STATE_BASE_ADDRESS");
2865 state_base_out(data, hw_offset, i++, "general");
2866 state_base_out(data, hw_offset, i++, "surface");
2867 if (IS_GEN6(devid) || IS_GEN7(devid))
2868 state_base_out(data, hw_offset, i++, "dynamic");
2869 state_base_out(data, hw_offset, i++, "indirect");
2870 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2871 state_base_out(data, hw_offset, i++, "instruction");
2873 state_max_out(data, hw_offset, i++, "general");
2874 if (IS_GEN6(devid) || IS_GEN7(devid))
2875 state_max_out(data, hw_offset, i++, "dynamic");
2876 state_max_out(data, hw_offset, i++, "indirect");
2877 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2878 state_max_out(data, hw_offset, i++, "instruction");
2884 "Bad count in 3DSTATE_PIPELINED_POINTERS\n");
2886 BUFFER_FAIL(count, len, "3DSTATE_PIPELINED_POINTERS");
2888 instr_out(data, hw_offset, 0, "3DSTATE_PIPELINED_POINTERS\n");
2889 instr_out(data, hw_offset, 1, "VS state\n");
2890 instr_out(data, hw_offset, 2, "GS state\n");
2891 instr_out(data, hw_offset, 3, "Clip state\n");
2892 instr_out(data, hw_offset, 4, "SF state\n");
2893 instr_out(data, hw_offset, 5, "WM state\n");
2894 instr_out(data, hw_offset, 6, "CC state\n");
2897 len = (data[0] & 0x000000ff) + 2;
2898 if (len != 6 && len != 4)
2900 "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
2903 BUFFER_FAIL(count, len,
2904 "3DSTATE_BINDING_TABLE_POINTERS");
2905 instr_out(data, hw_offset, 0,
2906 "3DSTATE_BINDING_TABLE_POINTERS\n");
2907 instr_out(data, hw_offset, 1, "VS binding table\n");
2908 instr_out(data, hw_offset, 2, "GS binding table\n");
2909 instr_out(data, hw_offset, 3, "Clip binding table\n");
2910 instr_out(data, hw_offset, 4, "SF binding table\n");
2911 instr_out(data, hw_offset, 5, "WM binding table\n");
2914 BUFFER_FAIL(count, len,
2915 "3DSTATE_BINDING_TABLE_POINTERS");
2917 instr_out(data, hw_offset, 0,
2918 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
2919 "GS mod %d, PS mod %d\n",
2920 (data[0] & (1 << 8)) != 0,
2921 (data[0] & (1 << 9)) != 0,
2922 (data[0] & (1 << 12)) != 0);
2923 instr_out(data, hw_offset, 1, "VS binding table\n");
2924 instr_out(data, hw_offset, 2, "GS binding table\n");
2925 instr_out(data, hw_offset, 3, "WM binding table\n");
2930 len = (data[0] & 0xff) + 2;
2933 "Bad count in 3DSTATE_SAMPLER_STATE_POINTERS\n");
2935 BUFFER_FAIL(count, len,
2936 "3DSTATE_SAMPLER_STATE_POINTERS");
2937 instr_out(data, hw_offset, 0,
2938 "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
2939 "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
2940 (data[0] & (1 << 9)) != 0,
2941 (data[0] & (1 << 12)) != 0);
2942 instr_out(data, hw_offset, 1, "VS sampler state\n");
2943 instr_out(data, hw_offset, 2, "GS sampler state\n");
2944 instr_out(data, hw_offset, 3, "WM sampler state\n");
2947 len = (data[0] & 0xff) + 2;
2949 fprintf(out, "Bad count in 3DSTATE_URB\n");
2951 BUFFER_FAIL(count, len, "3DSTATE_URB");
2952 instr_out(data, hw_offset, 0, "3DSTATE_URB\n");
2953 instr_out(data, hw_offset, 1,
2954 "VS entries %d, alloc size %d (1024bit row)\n",
2955 data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1);
2956 instr_out(data, hw_offset, 2,
2957 "GS entries %d, alloc size %d (1024bit row)\n",
2958 (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1);
2962 len = (data[0] & 0xff) + 2;
2963 if ((len - 1) % 4 != 0)
2964 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
2966 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_BUFFERS");
2967 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_BUFFERS\n");
2969 for (i = 1; i < len;) {
2971 if (IS_GEN6(devid)) {
2978 instr_out(data, hw_offset, i,
2979 "buffer %d: %s, pitch %db\n", data[i] >> idx,
2980 data[i] & (1 << access) ? "random" :
2981 "sequential", data[i] & 0x07ff);
2983 instr_out(data, hw_offset, i++, "buffer address\n");
2984 instr_out(data, hw_offset, i++, "max index\n");
2985 instr_out(data, hw_offset, i++, "mbz\n");
2990 len = (data[0] & 0xff) + 2;
2991 if ((len + 1) % 2 != 0)
2992 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
2994 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_ELEMENTS");
2995 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_ELEMENTS\n");
2997 for (i = 1; i < len;) {
2998 instr_out(data, hw_offset, i,
2999 "buffer %d: %svalid, type 0x%04x, "
3000 "src offset 0x%04x bytes\n",
3001 data[i] >> (IS_GEN6(devid) ? 26 : 27),
3002 data[i] & (1 << (IS_GEN6(devid) ? 25 : 26)) ?
3003 "" : "in", (data[i] >> 16) & 0x1ff,
3006 instr_out(data, hw_offset, i, "(%s, %s, %s, %s), "
3007 "dst offset 0x%02x bytes\n",
3008 get_965_element_component(data[i], 0),
3009 get_965_element_component(data[i], 1),
3010 get_965_element_component(data[i], 2),
3011 get_965_element_component(data[i], 3),
3012 (data[i] & 0xff) * 4);
3018 len = (data[0] & 0xff) + 2;
3021 "Bad count in 3DSTATE_VIEWPORT_STATE_POINTERS\n");
3023 BUFFER_FAIL(count, len,
3024 "3DSTATE_VIEWPORT_STATE_POINTERS");
3025 instr_out(data, hw_offset, 0,
3026 "3DSTATE_VIEWPORT_STATE_POINTERS\n");
3027 instr_out(data, hw_offset, 1, "clip\n");
3028 instr_out(data, hw_offset, 2, "sf\n");
3029 instr_out(data, hw_offset, 3, "cc\n");
3033 len = (data[0] & 0xff) + 2;
3035 fprintf(out, "Bad count in 3DSTATE_INDEX_BUFFER\n");
3037 BUFFER_FAIL(count, len, "3DSTATE_INDEX_BUFFER");
3038 instr_out(data, hw_offset, 0, "3DSTATE_INDEX_BUFFER\n");
3039 instr_out(data, hw_offset, 1, "beginning buffer address\n");
3040 instr_out(data, hw_offset, 2, "ending buffer address\n");
3044 len = (data[0] & 0xff) + 2;
3047 "Bad count in 3DSTATE_CC_STATE_POINTERS\n");
3049 BUFFER_FAIL(count, len, "3DSTATE_CC_STATE_POINTERS");
3050 instr_out(data, hw_offset, 0, "3DSTATE_CC_STATE_POINTERS\n");
3051 instr_out(data, hw_offset, 1, "blend change %d\n", data[1] & 1);
3052 instr_out(data, hw_offset, 2, "depth stencil change %d\n",
3054 instr_out(data, hw_offset, 3, "cc change %d\n", data[3] & 1);
3058 len = (data[0] & 0xff) + 2;
3060 fprintf(out, "Bad count in 3DSTATE_SCISSOR_POINTERS\n");
3062 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_POINTERS");
3063 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_POINTERS\n");
3064 instr_out(data, hw_offset, 1, "scissor rect offset\n");
3068 len = (data[0] & 0xff) + 2;
3070 fprintf(out, "Bad count in 3DSTATE_VS\n");
3072 BUFFER_FAIL(count, len, "3DSTATE_VS");
3073 instr_out(data, hw_offset, 0, "3DSTATE_VS\n");
3074 instr_out(data, hw_offset, 1, "kernel pointer\n");
3075 instr_out(data, hw_offset, 2,
3076 "SPF=%d, VME=%d, Sampler Count %d, "
3077 "Binding table count %d\n", (data[2] >> 31) & 1,
3078 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3079 (data[2] >> 18) & 0xff);
3080 instr_out(data, hw_offset, 3, "scratch offset\n");
3081 instr_out(data, hw_offset, 4,
3082 "Dispatch GRF start %d, VUE read length %d, "
3083 "VUE read offset %d\n", (data[4] >> 20) & 0x1f,
3084 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3085 instr_out(data, hw_offset, 5,
3086 "Max Threads %d, Vertex Cache %sable, "
3087 "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1,
3088 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
3089 (data[5] & 1) != 0 ? "en" : "dis");
3093 len = (data[0] & 0xff) + 2;
3095 fprintf(out, "Bad count in 3DSTATE_GS\n");
3097 BUFFER_FAIL(count, len, "3DSTATE_GS");
3098 instr_out(data, hw_offset, 0, "3DSTATE_GS\n");
3099 instr_out(data, hw_offset, 1, "kernel pointer\n");
3100 instr_out(data, hw_offset, 2,
3101 "SPF=%d, VME=%d, Sampler Count %d, "
3102 "Binding table count %d\n", (data[2] >> 31) & 1,
3103 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3104 (data[2] >> 18) & 0xff);
3105 instr_out(data, hw_offset, 3, "scratch offset\n");
3106 instr_out(data, hw_offset, 4,
3107 "Dispatch GRF start %d, VUE read length %d, "
3108 "VUE read offset %d\n", (data[4] & 0xf),
3109 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3110 instr_out(data, hw_offset, 5,
3111 "Max Threads %d, Rendering %sable\n",
3112 ((data[5] >> 25) & 0x7f) + 1,
3113 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
3114 instr_out(data, hw_offset, 6,
3115 "Reorder %sable, Discard Adjaceny %sable, "
3117 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
3118 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
3119 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
3123 len = (data[0] & 0xff) + 2;
3125 fprintf(out, "Bad count in 3DSTATE_CLIP\n");
3127 BUFFER_FAIL(count, len, "3DSTATE_CLIP");
3128 instr_out(data, hw_offset, 0, "3DSTATE_CLIP\n");
3129 instr_out(data, hw_offset, 1,
3130 "UserClip distance cull test mask 0x%x\n",
3132 instr_out(data, hw_offset, 2,
3133 "Clip %sable, API mode %s, Viewport XY test %sable, "
3134 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
3135 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
3136 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
3137 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
3138 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
3139 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
3140 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
3141 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
3142 (data[2] >> 13) & 7,
3143 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
3144 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
3145 (data[2] >> 4) & 3, (data[2] >> 2) & 3,
3147 instr_out(data, hw_offset, 3,
3148 "Min PointWidth %d, Max PointWidth %d, "
3149 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
3150 (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff,
3151 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
3156 len = (data[0] & 0xff) + 2;
3158 fprintf(out, "Bad count in 3DSTATE_SF\n");
3160 BUFFER_FAIL(count, len, "3DSTATE_SF");
3161 instr_out(data, hw_offset, 0, "3DSTATE_SF\n");
3162 instr_out(data, hw_offset, 1,
3163 "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
3164 "VUE read offset %d\n", (data[1] >> 22) & 0x3f,
3165 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
3166 (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f);
3167 instr_out(data, hw_offset, 2,
3168 "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
3169 "VP transform %sable, FrontWinding_%s\n",
3170 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
3171 (data[2] >> 5) & 3, (data[2] >> 3) & 3,
3172 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
3173 (data[2] & 1) != 0 ? "CCW" : "CW");
3174 instr_out(data, hw_offset, 3,
3175 "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
3176 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
3177 (data[3] >> 29) & 3,
3178 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
3179 (data[3] >> 8) & 3);
3180 instr_out(data, hw_offset, 4,
3181 "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
3182 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
3183 (data[4] & (1 << 12)) != 0 ? 4 : 8,
3184 (data[4] & (1 << 11)) != 0);
3185 instr_out(data, hw_offset, 5,
3186 "Global Depth Offset Constant %f\n", data[5]);
3187 instr_out(data, hw_offset, 6, "Global Depth Offset Scale %f\n",
3189 instr_out(data, hw_offset, 7, "Global Depth Offset Clamp %f\n",
3192 for (i = 0, j = 0; i < 8; i++, j += 2)
3193 instr_out(data, hw_offset, i + 8,
3194 "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, "
3195 "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n",
3197 (data[8 + i] & (1 << 31)) != 0 ? "W" : "",
3198 (data[8 + i] & (1 << 30)) != 0 ? "Z" : "",
3199 (data[8 + i] & (1 << 29)) != 0 ? "Y" : "",
3200 (data[8 + i] & (1 << 28)) != 0 ? "X" : "",
3201 (data[8 + i] >> 25) & 3,
3202 (data[8 + i] >> 22) & 3,
3203 (data[8 + i] >> 16) & 0x1f, j,
3204 (data[8 + i] & (1 << 15)) != 0 ? "W" : "",
3205 (data[8 + i] & (1 << 14)) != 0 ? "Z" : "",
3206 (data[8 + i] & (1 << 13)) != 0 ? "Y" : "",
3207 (data[8 + i] & (1 << 12)) != 0 ? "X" : "",
3208 (data[8 + i] >> 9) & 3,
3209 (data[8 + i] >> 6) & 3, (data[8 + i] & 0x1f));
3210 instr_out(data, hw_offset, 16,
3211 "Point Sprite TexCoord Enable\n");
3212 instr_out(data, hw_offset, 17, "Const Interp Enable\n");
3213 instr_out(data, hw_offset, 18,
3214 "Attrib 7-0 WrapShortest Enable\n");
3215 instr_out(data, hw_offset, 19,
3216 "Attrib 15-8 WrapShortest Enable\n");
3221 len = (data[0] & 0xff) + 2;
3223 fprintf(out, "Bad count in 3DSTATE_WM\n");
3225 BUFFER_FAIL(count, len, "3DSTATE_WM");
3226 instr_out(data, hw_offset, 0, "3DSTATE_WM\n");
3227 instr_out(data, hw_offset, 1, "kernel start pointer 0\n");
3228 instr_out(data, hw_offset, 2,
3229 "SPF=%d, VME=%d, Sampler Count %d, "
3230 "Binding table count %d\n", (data[2] >> 31) & 1,
3231 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3232 (data[2] >> 18) & 0xff);
3233 instr_out(data, hw_offset, 3, "scratch offset\n");
3234 instr_out(data, hw_offset, 4,
3235 "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, "
3236 "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n",
3237 (data[4] & (1 << 30)) != 0,
3238 (data[4] & (1 << 28)) != 0,
3239 (data[4] & (1 << 27)) != 0, (data[4] >> 16) & 0x7f,
3240 (data[4] >> 8) & 0x7f, (data[4] & 0x7f));
3241 instr_out(data, hw_offset, 5,
3242 "MaxThreads %d, PS KillPixel %d, PS computed Z %d, "
3243 "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, Dispatch32 %d, "
3244 "Dispatch16 %d, Dispatch8 %d\n",
3245 ((data[5] >> 25) & 0x7f) + 1,
3246 (data[5] & (1 << 22)) != 0,
3247 (data[5] & (1 << 21)) != 0,
3248 (data[5] & (1 << 20)) != 0,
3249 (data[5] & (1 << 19)) != 0, (data[5] & (1 << 8)) != 0,
3250 (data[5] & (1 << 2)) != 0, (data[5] & (1 << 1)) != 0,
3251 (data[5] & (1 << 0)) != 0);
3252 instr_out(data, hw_offset, 6,
3253 "Num SF output %d, Pos XY offset %d, ZW interp mode %d , "
3254 "Barycentric interp mode 0x%x, Point raster rule %d, Multisample mode %d, "
3255 "Multisample Dispatch mode %d\n",
3256 (data[6] >> 20) & 0x3f, (data[6] >> 18) & 3,
3257 (data[6] >> 16) & 3, (data[6] >> 10) & 0x3f,
3258 (data[6] & (1 << 9)) != 0, (data[6] >> 1) & 3,
3260 instr_out(data, hw_offset, 7, "kernel start pointer 1\n");
3261 instr_out(data, hw_offset, 8, "kernel start pointer 2\n");
3268 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
3270 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
3272 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
3273 instr_out(data, hw_offset, 1, "top left: %d,%d\n",
3274 data[1] & 0xffff, (data[1] >> 16) & 0xffff);
3275 instr_out(data, hw_offset, 2, "bottom right: %d,%d\n",
3276 data[2] & 0xffff, (data[2] >> 16) & 0xffff);
3277 instr_out(data, hw_offset, 3, "origin: %d,%d\n",
3278 (int)data[3] & 0xffff, ((int)data[3] >> 16) & 0xffff);
3283 if (len < 5 || len > 7)
3284 fprintf(out, "Bad count in 3DSTATE_DEPTH_BUFFER\n");
3286 BUFFER_FAIL(count, len, "3DSTATE_DEPTH_BUFFER");
3288 instr_out(data, hw_offset, 0, "3DSTATE_DEPTH_BUFFER\n");
3289 if (IS_GEN5(devid) || IS_GEN6(devid))
3290 instr_out(data, hw_offset, 1,
3291 "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Seperate Stencil %d\n",
3292 get_965_surfacetype(data[1] >> 29),
3293 get_965_depthformat((data[1] >> 18) & 0x7),
3294 (data[1] & 0x0001ffff) + 1,
3295 data[1] & (1 << 27) ? "" : "not ",
3296 (data[1] & (1 << 22)) != 0,
3297 (data[1] & (1 << 21)) != 0);
3299 instr_out(data, hw_offset, 1,
3300 "%s, %s, pitch = %d bytes, %stiled\n",
3301 get_965_surfacetype(data[1] >> 29),
3302 get_965_depthformat((data[1] >> 18) & 0x7),
3303 (data[1] & 0x0001ffff) + 1,
3304 data[1] & (1 << 27) ? "" : "not ");
3305 instr_out(data, hw_offset, 2, "depth offset\n");
3306 instr_out(data, hw_offset, 3, "%dx%d\n",
3307 ((data[3] & 0x0007ffc0) >> 6) + 1,
3308 ((data[3] & 0xfff80000) >> 19) + 1);
3309 instr_out(data, hw_offset, 4, "volume depth\n");
3311 instr_out(data, hw_offset, 5, "\n");
3314 instr_out(data, hw_offset, 6, "\n");
3316 instr_out(data, hw_offset, 6,
3317 "render target view extent\n");
3323 if (IS_GEN6(devid) || IS_GEN7(devid)) {
3325 len = (data[0] & 0xff) + 2;
3326 if (len != 4 && len != 5)
3327 fprintf(out, "Bad count in PIPE_CONTROL\n");
3329 BUFFER_FAIL(count, len, "PIPE_CONTROL");
3331 switch ((data[1] >> 14) & 0x3) {
3336 desc1 = "qword write";
3339 desc1 = "PS_DEPTH_COUNT write";
3342 desc1 = "TIMESTAMP write";
3345 instr_out(data, hw_offset, 0, "PIPE_CONTROL\n");
3346 instr_out(data, hw_offset, 1,
3347 "%s, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
3349 data[1] & (1 << 20) ? "cs stall, " : "",
3350 data[1] & (1 << 19) ?
3351 "global snapshot count reset, " : "",
3352 data[1] & (1 << 18) ? "tlb invalidate, " : "",
3353 data[1] & (1 << 17) ? "gfdt flush, " : "",
3354 data[1] & (1 << 17) ? "media state clear, " :
3356 data[1] & (1 << 13) ? "depth stall, " : "",
3357 data[1] & (1 << 12) ?
3358 "render target cache flush, " : "",
3359 data[1] & (1 << 11) ?
3360 "instruction cache invalidate, " : "",
3361 data[1] & (1 << 10) ?
3362 "texture cache invalidate, " : "",
3363 data[1] & (1 << 9) ?
3364 "indirect state invalidate, " : "",
3365 data[1] & (1 << 8) ? "notify irq, " : "",
3366 data[1] & (1 << 7) ? "PIPE_CONTROL flush, " :
3368 data[1] & (1 << 6) ? "protect mem app_id, " :
3369 "", data[1] & (1 << 5) ? "DC flush, " : "",
3370 data[1] & (1 << 4) ? "vf fetch invalidate, " :
3372 data[1] & (1 << 3) ?
3373 "constant cache invalidate, " : "",
3374 data[1] & (1 << 2) ?
3375 "state cache invalidate, " : "",
3376 data[1] & (1 << 1) ? "stall at scoreboard, " :
3378 data[1] & (1 << 0) ? "depth cache flush, " :
3381 instr_out(data, hw_offset, 2,
3382 "destination address\n");
3383 instr_out(data, hw_offset, 3,
3384 "immediate dword low\n");
3385 instr_out(data, hw_offset, 4,
3386 "immediate dword high\n");
3388 for (i = 2; i < len; i++) {
3389 instr_out(data, hw_offset, i, "\n");
3394 len = (data[0] & 0xff) + 2;
3396 fprintf(out, "Bad count in PIPE_CONTROL\n");
3398 BUFFER_FAIL(count, len, "PIPE_CONTROL");
3400 switch ((data[0] >> 14) & 0x3) {
3405 desc1 = "qword write";
3408 desc1 = "PS_DEPTH_COUNT write";
3411 desc1 = "TIMESTAMP write";
3414 instr_out(data, hw_offset, 0,
3415 "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, "
3418 data[0] & (1 << 13) ? "" : "no ",
3419 data[0] & (1 << 12) ? "" : "no ",
3420 data[0] & (1 << 11) ? "" : "no ");
3421 instr_out(data, hw_offset, 1, "destination address\n");
3422 instr_out(data, hw_offset, 2, "immediate dword low\n");
3423 instr_out(data, hw_offset, 3, "immediate dword high\n");
3427 len = (data[0] & 0xff) + 2;
3429 fprintf(out, "Bad count in 3DPRIMITIVE\n");
3431 BUFFER_FAIL(count, len, "3DPRIMITIVE");
3433 instr_out(data, hw_offset, 0,
3434 "3DPRIMITIVE: %s %s\n",
3435 get_965_prim_type(data[0]),
3436 (data[0] & (1 << 15)) ? "random" : "sequential");
3437 instr_out(data, hw_offset, 1, "vertex count\n");
3438 instr_out(data, hw_offset, 2, "start vertex\n");
3439 instr_out(data, hw_offset, 3, "instance count\n");
3440 instr_out(data, hw_offset, 4, "start instance\n");
3441 instr_out(data, hw_offset, 5, "index bias\n");
3445 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3446 opcode_3d = &opcodes_3d[idx];
3447 if ((data[0] & 0xffff0000) >> 16 == opcode_3d->opcode) {
3451 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
3452 if (opcode_3d->max_len > 1) {
3453 len = (data[0] & 0xff) + 2;
3454 if (len < opcode_3d->min_len ||
3455 len > opcode_3d->max_len) {
3456 fprintf(out, "Bad count in %s\n",
3461 for (i = 1; i < len; i++) {
3463 BUFFER_FAIL(count, len,
3465 instr_out(data, hw_offset, i, "dword %d\n", i);
3471 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n",
3478 decode_3d_i830(uint32_t *data, uint32_t count, uint32_t hw_offset, uint32_t devid,
3486 unsigned int min_len;
3487 unsigned int max_len;
3490 { 0x02, 1, 1, "3DSTATE_MODES_3" },
3491 { 0x03, 1, 1, "3DSTATE_ENABLES_1" },
3492 { 0x04, 1, 1, "3DSTATE_ENABLES_2" },
3493 { 0x05, 1, 1, "3DSTATE_VFT0" },
3494 { 0x06, 1, 1, "3DSTATE_AA" },
3495 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" },
3496 { 0x08, 1, 1, "3DSTATE_MODES_1" },
3497 { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" },
3498 { 0x0a, 1, 1, "3DSTATE_VFT1" },
3499 { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" },
3500 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
3501 { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" },
3502 { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" },
3503 { 0x0f, 1, 1, "3DSTATE_MODES_2" },
3504 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
3505 { 0x16, 1, 1, "3DSTATE_MODES_4"},
3508 opcode = (data[0] & 0x1f000000) >> 24;
3512 return decode_3d_primitive(data, count, hw_offset, failures);
3514 return decode_3d_1d(data, count, hw_offset, devid, failures);
3516 return decode_3d_1c(data, count, hw_offset, failures);
3519 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
3520 opcode_3d = &opcodes_3d[idx];
3521 if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) {
3522 unsigned int len = 1, i;
3524 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
3525 if (opcode_3d->max_len > 1) {
3526 len = (data[0] & 0xff) + 2;
3527 if (len < opcode_3d->min_len ||
3528 len > opcode_3d->max_len) {
3529 fprintf(out, "Bad count in %s\n",
3534 for (i = 1; i < len; i++) {
3536 BUFFER_FAIL(count, len,
3538 instr_out(data, hw_offset, i, "dword %d\n", i);
3544 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n",
3550 struct drm_intel_decode *
3551 drm_intel_decode_context_alloc(uint32_t devid)
3553 struct drm_intel_decode *ctx;
3555 ctx = calloc(1, sizeof(struct drm_intel_decode));
3565 drm_intel_decode_context_free(struct drm_intel_decode *ctx)
3571 drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx,
3574 ctx->dump_past_end = !!dump_past_end;
3578 drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx,
3579 void *data, uint32_t hw_offset, int count)
3582 ctx->hw_offset = hw_offset;
3587 drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx,
3588 uint32_t head, uint32_t tail)
3595 * Decodes an i830-i915 batch buffer, writing the output to stdout.
3597 * \param data batch buffer contents
3598 * \param count number of DWORDs to decode in the batch buffer
3599 * \param hw_offset hardware address for the buffer
3602 drm_intel_decode(struct drm_intel_decode *ctx)
3605 unsigned int index = 0;
3608 uint32_t count, hw_offset;
3616 hw_offset = ctx->hw_offset;
3618 head_offset = ctx->head;
3619 tail_offset = ctx->tail;
3626 while (index < count) {
3627 switch ((data[index] & 0xe0000000) >> 29) {
3629 ret = decode_mi(data + index, count - index,
3630 hw_offset + index * 4, &failures);
3632 /* If MI_BATCHBUFFER_END happened, then dump
3633 * the rest of the output in case we some day
3634 * want it in debugging, but don't decode it
3635 * since it'll just confuse in the common
3639 if (ctx->dump_past_end) {
3642 for (index = index + 1; index < count;
3644 instr_out(data, hw_offset,
3652 index += decode_2d(data + index, count - index,
3653 hw_offset + index * 4, &failures);
3656 if (IS_9XX(devid) && !IS_GEN3(devid)) {
3658 decode_3d_965(data + index, count - index,
3659 hw_offset + index * 4, devid,
3661 } else if (IS_GEN3(devid)) {
3662 index += decode_3d(data + index, count - index,
3663 hw_offset + index * 4,
3667 decode_3d_i830(data + index, count - index,
3668 hw_offset + index * 4, devid,
3673 instr_out(data, hw_offset, index, "UNKNOWN\n");