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)) {
1285 instr_out(data, hw_offset, i,
1286 "S0: vbo offset: 0x%08x%s\n",
1289 ", auto cache invalidate disabled"
1293 instr_out(data, hw_offset, i,
1294 "S1: vertex width: %i, vertex pitch: %i\n",
1301 instr_out(data, hw_offset, i,
1302 "S2: texcoord formats: ");
1304 tex_num < 8; tex_num++) {
1349 instr_out(data, hw_offset, i,
1350 "S3: not documented\n");
1354 const char *cullmode = "";
1355 const char *vfmt_xyzw = "";
1356 switch ((data[i] >> 13)
1393 case 1 << 6 | 1 << 2:
1397 case 2 << 6 | 1 << 2:
1401 case 3 << 6 | 1 << 2:
1405 case 4 << 6 | 1 << 2:
1412 "S4: point_width=%i, line_width=%.1f,"
1413 "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s "
1476 "force default diffuse, "
1482 "force default specular, "
1488 "local depth ofs enable, "
1494 "point sprite enable, "
1509 "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, "
1510 "stencil_fail=%s, stencil_pass_z_fail=%s, "
1511 "stencil_pass_z_pass=%s, %s%s%s%s\n",
1541 " force default point size,"
1547 " last pixel enable,"
1553 " global depth ofs enable,"
1579 "stencil write enable, "
1585 "stencil test enable, "
1591 "color dither enable, "
1602 instr_out(data, hw_offset, i,
1603 "S6: %salpha_test=%s, alpha_ref=0x%x, "
1604 "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, "
1605 "%s%stristrip_provoking_vertex=%i\n",
1606 data[i] & (1 << 31) ?
1607 "alpha test enable, "
1615 data[i] & (1 << 15) ?
1616 "cbuf blend enable, "
1618 decode_blend_fact(data
1622 decode_blend_fact(data
1626 data[i] & (1 << 3) ?
1627 "depth write enable, "
1629 data[i] & (1 << 2) ?
1630 "cbuf write enable, "
1635 instr_out(data, hw_offset, i,
1636 "S7: depth offset constant: 0x%08x\n",
1641 instr_out(data, hw_offset, i,
1642 "S%d: 0x%08x\n", i, data[i]);
1649 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n");
1654 instr_out(data, hw_offset, 0,
1655 "3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1656 len = (data[0] & 0x0000000f) + 2;
1658 for (word = 6; word <= 14; word++) {
1659 if (data[0] & (1 << word)) {
1661 BUFFER_FAIL(count, len,
1662 "3DSTATE_LOAD_STATE_IMMEDIATE_2");
1665 instr_out(data, hw_offset, i++,
1667 else if (word >= 7 && word <= 10) {
1668 instr_out(data, hw_offset, i++,
1669 "TB%dC\n", word - 7);
1670 instr_out(data, hw_offset, i++,
1671 "TB%dA\n", word - 7);
1672 } else if (word >= 11 && word <= 14) {
1673 instr_out(data, hw_offset, i,
1674 "TM%dS0: offset=0x%08x, %s\n",
1676 data[i] & 0xfffffffe,
1677 data[i] & 1 ? "use fence" :
1680 instr_out(data, hw_offset, i,
1681 "TM%dS1: height=%i, width=%i, %s\n",
1682 word - 11, data[i] >> 21,
1683 (data[i] >> 10) & 0x3ff,
1684 data[i] & 2 ? (data[i] & 1 ?
1689 instr_out(data, hw_offset, i,
1690 "TM%dS2: pitch=%i, \n",
1692 ((data[i] >> 21) + 1) * 4);
1694 instr_out(data, hw_offset, i++,
1695 "TM%dS3\n", word - 11);
1696 instr_out(data, hw_offset, i++,
1697 "TM%dS4: dflt color\n",
1704 "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n");
1709 instr_out(data, hw_offset, 0, "3DSTATE_MAP_STATE\n");
1710 len = (data[0] & 0x0000003f) + 2;
1711 instr_out(data, hw_offset, 1, "mask\n");
1714 for (map = 0; map <= 15; map++) {
1715 if (data[1] & (1 << map)) {
1716 int width, height, pitch, dword;
1720 BUFFER_FAIL(count, len,
1721 "3DSTATE_MAP_STATE");
1724 instr_out(data, hw_offset, i++,
1725 "map %d MS2 %s%s%s\n", map,
1727 "untrusted surface, " : "",
1729 "vertical line stride enable, " : "",
1731 "vertical ofs enable, " : "");
1734 width = ((dword >> 10) & ((1 << 11) - 1)) + 1;
1735 height = ((dword >> 21) & ((1 << 11) - 1)) + 1;
1738 if (dword & (1 << 2))
1740 else if (dword & (1 << 1))
1741 tiling = dword & (1 << 0) ? "Y" : "X";
1744 switch ((dword >> 7) & 0x7) {
1747 switch ((dword >> 3) & 0xf) {
1764 switch ((dword >> 3) & 0xf) {
1769 format = " argb1555";
1772 format = " argb4444";
1778 format = " bump655";
1793 switch ((dword >> 3) & 0xf) {
1795 format = " argb8888";
1798 format = " abgr8888";
1801 format = " xrgb8888";
1804 format = " xbgr8888";
1807 format = " qwvu8888";
1810 format = " axvu8888";
1813 format = " lxvu8888";
1816 format = " xlvu8888";
1819 format = " argb2101010";
1822 format = " abgr2101010";
1825 format = " awvu2101010";
1846 switch ((dword >> 3) & 0xf) {
1848 format = " yuv_swapy";
1854 format = " yuv_swapuv";
1857 format = " yuv_swapuvy";
1862 type = "compressed";
1863 switch ((dword >> 3) & 0x7) {
1877 format = " dxt1_rb";
1882 type = "4b indexed";
1883 switch ((dword >> 3) & 0xf) {
1885 format = " argb8888";
1891 instr_out(data, hw_offset, i++,
1892 "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n",
1893 map, width, height, type, format,
1895 dword & (1 << 9) ? " palette select" :
1900 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1);
1901 instr_out(data, hw_offset, i++,
1902 "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n",
1903 map, pitch, (dword >> 9) & 0x3f,
1904 dword & 0xff, (dword >> 15) & 0x3f,
1905 dword & (1 << 8) ? "miplayout legacy"
1906 : "miplayout right");
1910 fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n");
1916 instr_out(data, hw_offset, 0,
1917 "3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1918 len = (data[0] & 0x000000ff) + 2;
1921 for (c = 0; c <= 31; c++) {
1922 if (data[1] & (1 << c)) {
1924 BUFFER_FAIL(count, len,
1925 "3DSTATE_PIXEL_SHADER_CONSTANTS");
1926 instr_out(data, hw_offset, i, "C%d.X = %f\n", c,
1927 int_as_float(data[i]));
1929 instr_out(data, hw_offset, i, "C%d.Y = %f\n",
1930 c, int_as_float(data[i]));
1932 instr_out(data, hw_offset, i, "C%d.Z = %f\n",
1933 c, int_as_float(data[i]));
1935 instr_out(data, hw_offset, i, "C%d.W = %f\n",
1936 c, int_as_float(data[i]));
1942 "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n");
1947 instr_out(data, hw_offset, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n");
1948 len = (data[0] & 0x000000ff) + 2;
1949 if ((len - 1) % 3 != 0 || len > 370) {
1951 "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n");
1955 for (instr = 0; instr < (len - 1) / 3; instr++) {
1956 char instr_prefix[10];
1959 BUFFER_FAIL(count, len,
1960 "3DSTATE_PIXEL_SHADER_PROGRAM");
1961 sprintf(instr_prefix, "PS%03d", instr);
1962 i915_decode_instruction(data, hw_offset, i,
1970 instr_out(data, hw_offset, 0, "3DSTATE_SAMPLER_STATE\n");
1971 instr_out(data, hw_offset, 1, "mask\n");
1972 len = (data[0] & 0x0000003f) + 2;
1974 for (sampler = 0; sampler <= 15; sampler++) {
1975 if (data[1] & (1 << sampler)) {
1977 const char *mip_filter = "";
1979 BUFFER_FAIL(count, len,
1980 "3DSTATE_SAMPLER_STATE");
1982 switch ((dword >> 20) & 0x3) {
1984 mip_filter = "none";
1987 mip_filter = "nearest";
1990 mip_filter = "linear";
1993 instr_out(data, hw_offset, i++,
1994 "sampler %d SS2:%s%s%s "
1995 "base_mip_level=%i, mip_filter=%s, mag_filter=%s, min_filter=%s "
1996 "lod_bias=%.2f,%s max_aniso=%i, shadow_func=%s\n",
1998 dword & (1 << 31) ? " reverse gamma,"
2000 dword & (1 << 30) ? " packed2planar,"
2003 " colorspace conversion," : "",
2004 (dword >> 22) & 0x1f, mip_filter,
2005 decode_sample_filter(dword >> 17),
2006 decode_sample_filter(dword >> 14),
2007 ((dword >> 5) & 0x1ff) / (0x10 * 1.0),
2008 dword & (1 << 4) ? " shadow," : "",
2009 dword & (1 << 3) ? 4 : 2,
2010 decode_compare_func(dword));
2012 instr_out(data, hw_offset, i++,
2013 "sampler %d SS3: min_lod=%.2f,%s "
2014 "tcmode_x=%s, tcmode_y=%s, tcmode_z=%s,%s texmap_idx=%i,%s\n",
2016 ((dword >> 24) & 0xff) / (0x10 * 1.0),
2018 " kill pixel enable," : "",
2019 decode_tex_coord_mode(dword >> 12),
2020 decode_tex_coord_mode(dword >> 9),
2021 decode_tex_coord_mode(dword >> 6),
2023 " normalized coords," : "",
2025 dword & (1 << 0) ? " deinterlacer," :
2028 instr_out(data, hw_offset, i++,
2029 "sampler %d SS4: border color\n",
2034 fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n");
2039 len = (data[0] & 0x0000000f) + 2;
2043 "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n");
2045 BUFFER_FAIL(count, len,
2046 "3DSTATE_DEST_BUFFER_VARIABLES");
2048 instr_out(data, hw_offset, 0,
2049 "3DSTATE_DEST_BUFFER_VARIABLES\n");
2051 switch ((data[1] >> 8) & 0xf) {
2056 format = "x1r5g5b5";
2062 format = "a8r8g8b8";
2065 format = "ycrcb_swapy";
2068 format = "ycrcb_normal";
2071 format = "ycrcb_swapuv";
2074 format = "ycrcb_swapuvy";
2077 format = "a4r4g4b4";
2080 format = "a1r5g5b5";
2083 format = "a2r10g10b10";
2089 switch ((data[1] >> 2) & 0x3) {
2103 instr_out(data, hw_offset, 1,
2104 "%s format, %s depth format, early Z %sabled\n",
2106 (data[1] & (1 << 31)) ? "en" : "dis");
2111 const char *name, *tiling;
2113 len = (data[0] & 0x0000000f) + 2;
2116 "Bad count in 3DSTATE_BUFFER_INFO\n");
2118 BUFFER_FAIL(count, len, "3DSTATE_BUFFER_INFO");
2120 switch ((data[1] >> 24) & 0x7) {
2133 if (data[1] & (1 << 23))
2135 else if (data[1] & (1 << 22))
2136 tiling = data[1] & (1 << 21) ? "Y" : "X";
2138 instr_out(data, hw_offset, 0, "3DSTATE_BUFFER_INFO\n");
2139 instr_out(data, hw_offset, 1,
2140 "%s, tiling = %s, pitch=%d\n", name, tiling,
2143 instr_out(data, hw_offset, 2, "address\n");
2147 len = (data[0] & 0x0000000f) + 2;
2151 "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n");
2153 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_RECTANGLE");
2155 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_RECTANGLE\n");
2156 instr_out(data, hw_offset, 1, "(%d,%d)\n",
2157 data[1] & 0xffff, data[1] >> 16);
2158 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2159 data[2] & 0xffff, data[2] >> 16);
2163 len = (data[0] & 0x0000000f) + 2;
2167 "Bad count in 3DSTATE_DRAWING_RECTANGLE\n");
2169 BUFFER_FAIL(count, len, "3DSTATE_DRAWING_RECTANGLE");
2171 instr_out(data, hw_offset, 0, "3DSTATE_DRAWING_RECTANGLE\n");
2172 instr_out(data, hw_offset, 1, "%s\n",
2173 data[1] & (1 << 30) ? "depth ofs disabled " : "");
2174 instr_out(data, hw_offset, 2, "(%d,%d)\n",
2175 data[2] & 0xffff, data[2] >> 16);
2176 instr_out(data, hw_offset, 3, "(%d,%d)\n",
2177 data[3] & 0xffff, data[3] >> 16);
2178 instr_out(data, hw_offset, 4, "(%d,%d)\n",
2179 data[4] & 0xffff, data[4] >> 16);
2183 len = (data[0] & 0x0000000f) + 2;
2186 fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n");
2188 BUFFER_FAIL(count, len, "3DSTATE_CLEAR_PARAMETERS");
2190 instr_out(data, hw_offset, 0, "3DSTATE_CLEAR_PARAMETERS\n");
2191 instr_out(data, hw_offset, 1, "prim_type=%s, clear=%s%s%s\n",
2192 data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT",
2193 data[1] & (1 << 2) ? "color," : "",
2194 data[1] & (1 << 1) ? "depth," : "",
2195 data[1] & (1 << 0) ? "stencil," : "");
2196 instr_out(data, hw_offset, 2, "clear color\n");
2197 instr_out(data, hw_offset, 3, "clear depth/stencil\n");
2198 instr_out(data, hw_offset, 4, "color value (rgba8888)\n");
2199 instr_out(data, hw_offset, 5, "depth value %f\n",
2200 int_as_float(data[5]));
2201 instr_out(data, hw_offset, 6, "clear stencil\n");
2205 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) {
2206 opcode_3d_1d = &opcodes_3d_1d[idx];
2207 if (opcode_3d_1d->i830_only && !IS_GEN2(devid))
2210 if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) {
2213 instr_out(data, hw_offset, 0, "%s\n",
2214 opcode_3d_1d->name);
2215 if (opcode_3d_1d->max_len > 1) {
2216 len = (data[0] & 0x0000ffff) + 2;
2217 if (len < opcode_3d_1d->min_len ||
2218 len > opcode_3d_1d->max_len) {
2219 fprintf(out, "Bad count in %s\n",
2220 opcode_3d_1d->name);
2225 for (i = 1; i < len; i++) {
2227 BUFFER_FAIL(count, len,
2228 opcode_3d_1d->name);
2229 instr_out(data, hw_offset, i, "dword %d\n", i);
2236 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n",
2243 decode_3d_primitive(uint32_t *data, uint32_t count, uint32_t hw_offset,
2246 char immediate = (data[0] & (1 << 23)) == 0;
2247 unsigned int len, i, j, ret;
2248 const char *primtype;
2249 int original_s2 = saved_s2;
2250 int original_s4 = saved_s4;
2252 switch ((data[0] >> 18) & 0xf) {
2254 primtype = "TRILIST";
2257 primtype = "TRISTRIP";
2260 primtype = "TRISTRIP_REVERSE";
2263 primtype = "TRIFAN";
2266 primtype = "POLYGON";
2269 primtype = "LINELIST";
2272 primtype = "LINESTRIP";
2275 primtype = "RECTLIST";
2278 primtype = "POINTLIST";
2284 primtype = "CLEAR_RECT";
2289 primtype = "unknown";
2293 /* XXX: 3DPRIM_DIB not supported */
2295 len = (data[0] & 0x0003ffff) + 2;
2296 instr_out(data, hw_offset, 0, "3DPRIMITIVE inline %s\n",
2299 BUFFER_FAIL(count, len, "3DPRIMITIVE inline");
2300 if (!saved_s2_set || !saved_s4_set) {
2301 fprintf(out, "unknown vertex format\n");
2302 for (i = 1; i < len; i++) {
2303 instr_out(data, hw_offset, i,
2304 " vertex data (%f float)\n",
2305 int_as_float(data[i]));
2308 unsigned int vertex = 0;
2309 for (i = 1; i < len;) {
2312 #define VERTEX_OUT(fmt, ...) do { \
2314 instr_out(data, hw_offset, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \
2316 fprintf(out, " missing data in V%d\n", vertex); \
2320 VERTEX_OUT("X = %f", int_as_float(data[i]));
2321 VERTEX_OUT("Y = %f", int_as_float(data[i]));
2322 switch (saved_s4 >> 6 & 0x7) {
2324 VERTEX_OUT("Z = %f",
2325 int_as_float(data[i]));
2328 VERTEX_OUT("Z = %f",
2329 int_as_float(data[i]));
2330 VERTEX_OUT("W = %f",
2331 int_as_float(data[i]));
2336 VERTEX_OUT("W = %f",
2337 int_as_float(data[i]));
2340 fprintf(out, "bad S4 position mask\n");
2343 if (saved_s4 & (1 << 10)) {
2345 ("color = (A=0x%02x, R=0x%02x, G=0x%02x, "
2346 "B=0x%02x)", data[i] >> 24,
2347 (data[i] >> 16) & 0xff,
2348 (data[i] >> 8) & 0xff,
2351 if (saved_s4 & (1 << 11)) {
2353 ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, "
2354 "B=0x%02x)", data[i] >> 24,
2355 (data[i] >> 16) & 0xff,
2356 (data[i] >> 8) & 0xff,
2359 if (saved_s4 & (1 << 12))
2360 VERTEX_OUT("width = 0x%08x)", data[i]);
2362 for (tc = 0; tc <= 7; tc++) {
2363 switch ((saved_s2 >> (tc * 4)) & 0xf) {
2365 VERTEX_OUT("T%d.X = %f", tc,
2368 VERTEX_OUT("T%d.Y = %f", tc,
2373 VERTEX_OUT("T%d.X = %f", tc,
2376 VERTEX_OUT("T%d.Y = %f", tc,
2379 VERTEX_OUT("T%d.Z = %f", tc,
2384 VERTEX_OUT("T%d.X = %f", tc,
2387 VERTEX_OUT("T%d.Y = %f", tc,
2390 VERTEX_OUT("T%d.Z = %f", tc,
2393 VERTEX_OUT("T%d.W = %f", tc,
2398 VERTEX_OUT("T%d.X = %f", tc,
2404 ("T%d.XY = 0x%08x half-float",
2409 ("T%d.XY = 0x%08x half-float",
2412 ("T%d.ZW = 0x%08x half-float",
2419 "bad S2.T%d format\n",
2429 /* indirect vertices */
2430 len = data[0] & 0x0000ffff; /* index count */
2431 if (data[0] & (1 << 17)) {
2432 /* random vertex access */
2433 if (count < (len + 1) / 2 + 1) {
2434 BUFFER_FAIL(count, (len + 1) / 2 + 1,
2435 "3DPRIMITIVE random indirect");
2437 instr_out(data, hw_offset, 0,
2438 "3DPRIMITIVE random indirect %s (%d)\n",
2441 /* vertex indices continue until 0xffff is
2444 for (i = 1; i < count; i++) {
2445 if ((data[i] & 0xffff) == 0xffff) {
2446 instr_out(data, hw_offset, i,
2447 " indices: (terminator)\n");
2450 } else if ((data[i] >> 16) == 0xffff) {
2451 instr_out(data, hw_offset, i,
2452 " indices: 0x%04x, (terminator)\n",
2457 instr_out(data, hw_offset, i,
2458 " indices: 0x%04x, 0x%04x\n",
2464 "3DPRIMITIVE: no terminator found in index buffer\n");
2469 /* fixed size vertex index buffer */
2470 for (j = 1, i = 0; i < len; i += 2, j++) {
2471 if (i * 2 == len - 1) {
2472 instr_out(data, hw_offset, j,
2473 " indices: 0x%04x\n",
2476 instr_out(data, hw_offset, j,
2477 " indices: 0x%04x, 0x%04x\n",
2483 ret = (len + 1) / 2 + 1;
2486 /* sequential vertex access */
2488 BUFFER_FAIL(count, 2,
2489 "3DPRIMITIVE seq indirect");
2490 instr_out(data, hw_offset, 0,
2491 "3DPRIMITIVE sequential indirect %s, %d starting from "
2492 "%d\n", primtype, len, data[1] & 0xffff);
2493 instr_out(data, hw_offset, 1, " start\n");
2500 saved_s2 = original_s2;
2501 saved_s4 = original_s4;
2506 decode_3d(uint32_t *data, uint32_t count, uint32_t hw_offset, uint32_t devid,
2514 unsigned int min_len;
2515 unsigned int max_len;
2518 { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" },
2519 { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" },
2520 { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" },
2521 { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" },
2522 { 0x15, 1, 1, "3DSTATE_FOG_COLOR" },
2523 { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" },
2524 { 0x0d, 1, 1, "3DSTATE_MODES_4" },
2525 { 0x0c, 1, 1, "3DSTATE_MODES_5" },
2526 { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES"},
2529 opcode = (data[0] & 0x1f000000) >> 24;
2533 return decode_3d_primitive(data, count, hw_offset, failures);
2535 return decode_3d_1d(data, count, hw_offset, devid, failures);
2537 return decode_3d_1c(data, count, hw_offset, failures);
2540 for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) {
2541 opcode_3d = &opcodes_3d[idx];
2542 if (opcode == opcode_3d->opcode) {
2543 unsigned int len = 1, i;
2545 instr_out(data, hw_offset, 0, "%s\n", opcode_3d->name);
2546 if (opcode_3d->max_len > 1) {
2547 len = (data[0] & 0xff) + 2;
2548 if (len < opcode_3d->min_len ||
2549 len > opcode_3d->max_len) {
2550 fprintf(out, "Bad count in %s\n",
2555 for (i = 1; i < len; i++) {
2557 BUFFER_FAIL(count, len,
2559 instr_out(data, hw_offset, i, "dword %d\n", i);
2565 instr_out(data, hw_offset, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode);
2570 static const char *get_965_surfacetype(unsigned int surfacetype)
2572 switch (surfacetype) {
2590 static const char *get_965_depthformat(unsigned int depthformat)
2592 switch (depthformat) {
2594 return "s8_z24float";
2606 static const char *get_965_element_component(uint32_t data, int component)
2608 uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7;
2610 switch (component_control) {
2614 switch (component) {
2639 static const char *get_965_prim_type(uint32_t data)
2641 uint32_t primtype = (data >> 10) & 0x1f;
2645 return "point list";
2649 return "line strip";
2659 return "quad strip";
2661 return "line list adj";
2663 return "line strip adj";
2665 return "tri list adj";
2667 return "tri strip adj";
2669 return "tri strip reverse";
2677 return "point list bf";
2679 return "line strip cont";
2681 return "line strip bf";
2683 return "line strip cont bf";
2685 return "tri fan no stipple";
2692 i965_decode_urb_fence(uint32_t *data, uint32_t hw_offset, int len, uint32_t count,
2695 uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence;
2698 fprintf(out, "Bad count in URB_FENCE\n");
2700 BUFFER_FAIL(count, len, "URB_FENCE");
2702 vs_fence = data[1] & 0x3ff;
2703 gs_fence = (data[1] >> 10) & 0x3ff;
2704 clip_fence = (data[1] >> 20) & 0x3ff;
2705 sf_fence = data[2] & 0x3ff;
2706 vfe_fence = (data[2] >> 10) & 0x3ff;
2707 cs_fence = (data[2] >> 20) & 0x7ff;
2709 instr_out(data, hw_offset, 0, "URB_FENCE: %s%s%s%s%s%s\n",
2710 (data[0] >> 13) & 1 ? "cs " : "",
2711 (data[0] >> 12) & 1 ? "vfe " : "",
2712 (data[0] >> 11) & 1 ? "sf " : "",
2713 (data[0] >> 10) & 1 ? "clip " : "",
2714 (data[0] >> 9) & 1 ? "gs " : "",
2715 (data[0] >> 8) & 1 ? "vs " : "");
2716 instr_out(data, hw_offset, 1,
2717 "vs fence: %d, clip_fence: %d, gs_fence: %d\n",
2718 vs_fence, clip_fence, gs_fence);
2719 instr_out(data, hw_offset, 2,
2720 "sf fence: %d, vfe_fence: %d, cs_fence: %d\n",
2721 sf_fence, vfe_fence, cs_fence);
2722 if (gs_fence < vs_fence)
2723 fprintf(out, "gs fence < vs fence!\n");
2724 if (clip_fence < gs_fence)
2725 fprintf(out, "clip fence < gs fence!\n");
2726 if (sf_fence < clip_fence)
2727 fprintf(out, "sf fence < clip fence!\n");
2728 if (cs_fence < sf_fence)
2729 fprintf(out, "cs fence < sf fence!\n");
2735 state_base_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2738 if (data[index] & 1) {
2739 instr_out(data, hw_offset, index,
2740 "%s state base address 0x%08x\n", name,
2743 instr_out(data, hw_offset, index, "%s state base not updated\n",
2749 state_max_out(uint32_t *data, uint32_t hw_offset, unsigned int index,
2752 if (data[index] & 1) {
2753 if (data[index] == 1) {
2754 instr_out(data, hw_offset, index,
2755 "%s state upper bound disabled\n", name);
2757 instr_out(data, hw_offset, index,
2758 "%s state upper bound 0x%08x\n", name,
2762 instr_out(data, hw_offset, index,
2763 "%s state upper bound not updated\n", name);
2768 decode_3d_965(uint32_t *data, uint32_t count, uint32_t hw_offset, uint32_t devid,
2772 unsigned int idx, len;
2773 unsigned int i, j, sba_len;
2774 const char *desc1 = NULL;
2778 int unsigned min_len;
2779 int unsigned max_len;
2782 { 0x6000, 3, 3, "URB_FENCE" },
2783 { 0x6001, 2, 2, "CS_URB_STATE" },
2784 { 0x6002, 2, 2, "CONSTANT_BUFFER" },
2785 { 0x6101, 6, 6, "STATE_BASE_ADDRESS" },
2786 { 0x6102, 2, 2, "STATE_SIP" },
2787 { 0x6104, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2788 { 0x680b, 1, 1, "3DSTATE_VF_STATISTICS" },
2789 { 0x6904, 1, 1, "3DSTATE_PIPELINE_SELECT" },
2790 { 0x7800, 7, 7, "3DSTATE_PIPELINED_POINTERS" },
2791 { 0x7801, 6, 6, "3DSTATE_BINDING_TABLE_POINTERS" },
2792 { 0x7808, 5, 257, "3DSTATE_VERTEX_BUFFERS" },
2793 { 0x7809, 3, 256, "3DSTATE_VERTEX_ELEMENTS" },
2794 { 0x780a, 3, 3, "3DSTATE_INDEX_BUFFER" },
2795 { 0x780b, 1, 1, "3DSTATE_VF_STATISTICS" },
2796 { 0x7900, 4, 4, "3DSTATE_DRAWING_RECTANGLE" },
2797 { 0x7901, 5, 5, "3DSTATE_CONSTANT_COLOR" },
2798 { 0x7905, 5, 7, "3DSTATE_DEPTH_BUFFER" },
2799 { 0x7906, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" },
2800 { 0x7907, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" },
2801 { 0x7908, 3, 3, "3DSTATE_LINE_STIPPLE" },
2802 { 0x7909, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
2803 { 0x7909, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2804 { 0x790a, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
2805 { 0x790b, 4, 4, "3DSTATE_GS_SVB_INDEX" },
2806 { 0x790d, 3, 3, "3DSTATE_MULTISAMPLE" },
2807 { 0x7910, 2, 2, "3DSTATE_CLEAR_PARAMS" },
2808 { 0x7b00, 6, 6, "3DPRIMITIVE" },
2809 { 0x7802, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" },
2810 { 0x7805, 3, 3, "3DSTATE_URB" },
2811 { 0x780d, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" },
2812 { 0x780e, 4, 4, "3DSTATE_CC_STATE_POINTERS" },
2813 { 0x780f, 2, 2, "3DSTATE_SCISSOR_STATE_POINTERS" },
2814 { 0x7810, 6, 6, "3DSTATE_VS_STATE" },
2815 { 0x7811, 7, 7, "3DSTATE_GS_STATE" },
2816 { 0x7812, 4, 4, "3DSTATE_CLIP_STATE" },
2817 { 0x7813, 20, 20, "3DSTATE_SF_STATE" },
2818 { 0x7814, 9, 9, "3DSTATE_WM_STATE" },
2819 { 0x7815, 5, 5, "3DSTATE_CONSTANT_VS_STATE" },
2820 { 0x7816, 5, 5, "3DSTATE_CONSTANT_GS_STATE" },
2821 { 0x7817, 5, 5, "3DSTATE_CONSTANT_PS_STATE" },
2822 { 0x7818, 2, 2, "3DSTATE_SAMPLE_MASK"},
2825 len = (data[0] & 0x0000ffff) + 2;
2827 opcode = (data[0] & 0xffff0000) >> 16;
2830 len = (data[0] & 0x000000ff) + 2;
2831 return i965_decode_urb_fence(data, hw_offset, len, count,
2834 instr_out(data, hw_offset, 0, "CS_URB_STATE\n");
2835 instr_out(data, hw_offset, 1,
2836 "entry_size: %d [%d bytes], n_entries: %d\n",
2837 (data[1] >> 4) & 0x1f,
2838 (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7);
2841 len = (data[0] & 0x000000ff) + 2;
2842 instr_out(data, hw_offset, 0, "CONSTANT_BUFFER: %s\n",
2843 (data[0] >> 8) & 1 ? "valid" : "invalid");
2844 instr_out(data, hw_offset, 1,
2845 "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f,
2846 ((data[1] & 0x3f) + 1) * 64);
2850 instr_out(data, hw_offset, 0, "STATE_BASE_ADDRESS\n");
2853 if (IS_GEN6(devid) || IS_GEN7(devid))
2855 else if (IS_GEN5(devid))
2860 fprintf(out, "Bad count in STATE_BASE_ADDRESS\n");
2862 BUFFER_FAIL(count, len, "STATE_BASE_ADDRESS");
2864 state_base_out(data, hw_offset, i++, "general");
2865 state_base_out(data, hw_offset, i++, "surface");
2866 if (IS_GEN6(devid) || IS_GEN7(devid))
2867 state_base_out(data, hw_offset, i++, "dynamic");
2868 state_base_out(data, hw_offset, i++, "indirect");
2869 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2870 state_base_out(data, hw_offset, i++, "instruction");
2872 state_max_out(data, hw_offset, i++, "general");
2873 if (IS_GEN6(devid) || IS_GEN7(devid))
2874 state_max_out(data, hw_offset, i++, "dynamic");
2875 state_max_out(data, hw_offset, i++, "indirect");
2876 if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid))
2877 state_max_out(data, hw_offset, i++, "instruction");
2883 "Bad count in 3DSTATE_PIPELINED_POINTERS\n");
2885 BUFFER_FAIL(count, len, "3DSTATE_PIPELINED_POINTERS");
2887 instr_out(data, hw_offset, 0, "3DSTATE_PIPELINED_POINTERS\n");
2888 instr_out(data, hw_offset, 1, "VS state\n");
2889 instr_out(data, hw_offset, 2, "GS state\n");
2890 instr_out(data, hw_offset, 3, "Clip state\n");
2891 instr_out(data, hw_offset, 4, "SF state\n");
2892 instr_out(data, hw_offset, 5, "WM state\n");
2893 instr_out(data, hw_offset, 6, "CC state\n");
2896 len = (data[0] & 0x000000ff) + 2;
2897 if (len != 6 && len != 4)
2899 "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n");
2902 BUFFER_FAIL(count, len,
2903 "3DSTATE_BINDING_TABLE_POINTERS");
2904 instr_out(data, hw_offset, 0,
2905 "3DSTATE_BINDING_TABLE_POINTERS\n");
2906 instr_out(data, hw_offset, 1, "VS binding table\n");
2907 instr_out(data, hw_offset, 2, "GS binding table\n");
2908 instr_out(data, hw_offset, 3, "Clip binding table\n");
2909 instr_out(data, hw_offset, 4, "SF binding table\n");
2910 instr_out(data, hw_offset, 5, "WM binding table\n");
2913 BUFFER_FAIL(count, len,
2914 "3DSTATE_BINDING_TABLE_POINTERS");
2916 instr_out(data, hw_offset, 0,
2917 "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, "
2918 "GS mod %d, PS mod %d\n",
2919 (data[0] & (1 << 8)) != 0,
2920 (data[0] & (1 << 9)) != 0,
2921 (data[0] & (1 << 12)) != 0);
2922 instr_out(data, hw_offset, 1, "VS binding table\n");
2923 instr_out(data, hw_offset, 2, "GS binding table\n");
2924 instr_out(data, hw_offset, 3, "WM binding table\n");
2929 len = (data[0] & 0xff) + 2;
2932 "Bad count in 3DSTATE_SAMPLER_STATE_POINTERS\n");
2934 BUFFER_FAIL(count, len,
2935 "3DSTATE_SAMPLER_STATE_POINTERS");
2936 instr_out(data, hw_offset, 0,
2937 "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, "
2938 "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0,
2939 (data[0] & (1 << 9)) != 0,
2940 (data[0] & (1 << 12)) != 0);
2941 instr_out(data, hw_offset, 1, "VS sampler state\n");
2942 instr_out(data, hw_offset, 2, "GS sampler state\n");
2943 instr_out(data, hw_offset, 3, "WM sampler state\n");
2946 len = (data[0] & 0xff) + 2;
2948 fprintf(out, "Bad count in 3DSTATE_URB\n");
2950 BUFFER_FAIL(count, len, "3DSTATE_URB");
2951 instr_out(data, hw_offset, 0, "3DSTATE_URB\n");
2952 instr_out(data, hw_offset, 1,
2953 "VS entries %d, alloc size %d (1024bit row)\n",
2954 data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1);
2955 instr_out(data, hw_offset, 2,
2956 "GS entries %d, alloc size %d (1024bit row)\n",
2957 (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1);
2961 len = (data[0] & 0xff) + 2;
2962 if ((len - 1) % 4 != 0)
2963 fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n");
2965 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_BUFFERS");
2966 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_BUFFERS\n");
2968 for (i = 1; i < len;) {
2970 if (IS_GEN6(devid)) {
2977 instr_out(data, hw_offset, i,
2978 "buffer %d: %s, pitch %db\n", data[i] >> idx,
2979 data[i] & (1 << access) ? "random" :
2980 "sequential", data[i] & 0x07ff);
2982 instr_out(data, hw_offset, i++, "buffer address\n");
2983 instr_out(data, hw_offset, i++, "max index\n");
2984 instr_out(data, hw_offset, i++, "mbz\n");
2989 len = (data[0] & 0xff) + 2;
2990 if ((len + 1) % 2 != 0)
2991 fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n");
2993 BUFFER_FAIL(count, len, "3DSTATE_VERTEX_ELEMENTS");
2994 instr_out(data, hw_offset, 0, "3DSTATE_VERTEX_ELEMENTS\n");
2996 for (i = 1; i < len;) {
2997 instr_out(data, hw_offset, i,
2998 "buffer %d: %svalid, type 0x%04x, "
2999 "src offset 0x%04x bytes\n",
3000 data[i] >> (IS_GEN6(devid) ? 26 : 27),
3001 data[i] & (1 << (IS_GEN6(devid) ? 25 : 26)) ?
3002 "" : "in", (data[i] >> 16) & 0x1ff,
3005 instr_out(data, hw_offset, i, "(%s, %s, %s, %s), "
3006 "dst offset 0x%02x bytes\n",
3007 get_965_element_component(data[i], 0),
3008 get_965_element_component(data[i], 1),
3009 get_965_element_component(data[i], 2),
3010 get_965_element_component(data[i], 3),
3011 (data[i] & 0xff) * 4);
3017 len = (data[0] & 0xff) + 2;
3020 "Bad count in 3DSTATE_VIEWPORT_STATE_POINTERS\n");
3022 BUFFER_FAIL(count, len,
3023 "3DSTATE_VIEWPORT_STATE_POINTERS");
3024 instr_out(data, hw_offset, 0,
3025 "3DSTATE_VIEWPORT_STATE_POINTERS\n");
3026 instr_out(data, hw_offset, 1, "clip\n");
3027 instr_out(data, hw_offset, 2, "sf\n");
3028 instr_out(data, hw_offset, 3, "cc\n");
3032 len = (data[0] & 0xff) + 2;
3034 fprintf(out, "Bad count in 3DSTATE_INDEX_BUFFER\n");
3036 BUFFER_FAIL(count, len, "3DSTATE_INDEX_BUFFER");
3037 instr_out(data, hw_offset, 0, "3DSTATE_INDEX_BUFFER\n");
3038 instr_out(data, hw_offset, 1, "beginning buffer address\n");
3039 instr_out(data, hw_offset, 2, "ending buffer address\n");
3043 len = (data[0] & 0xff) + 2;
3046 "Bad count in 3DSTATE_CC_STATE_POINTERS\n");
3048 BUFFER_FAIL(count, len, "3DSTATE_CC_STATE_POINTERS");
3049 instr_out(data, hw_offset, 0, "3DSTATE_CC_STATE_POINTERS\n");
3050 instr_out(data, hw_offset, 1, "blend change %d\n", data[1] & 1);
3051 instr_out(data, hw_offset, 2, "depth stencil change %d\n",
3053 instr_out(data, hw_offset, 3, "cc change %d\n", data[3] & 1);
3057 len = (data[0] & 0xff) + 2;
3059 fprintf(out, "Bad count in 3DSTATE_SCISSOR_POINTERS\n");
3061 BUFFER_FAIL(count, len, "3DSTATE_SCISSOR_POINTERS");
3062 instr_out(data, hw_offset, 0, "3DSTATE_SCISSOR_POINTERS\n");
3063 instr_out(data, hw_offset, 1, "scissor rect offset\n");
3067 len = (data[0] & 0xff) + 2;
3069 fprintf(out, "Bad count in 3DSTATE_VS\n");
3071 BUFFER_FAIL(count, len, "3DSTATE_VS");
3072 instr_out(data, hw_offset, 0, "3DSTATE_VS\n");
3073 instr_out(data, hw_offset, 1, "kernel pointer\n");
3074 instr_out(data, hw_offset, 2,
3075 "SPF=%d, VME=%d, Sampler Count %d, "
3076 "Binding table count %d\n", (data[2] >> 31) & 1,
3077 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3078 (data[2] >> 18) & 0xff);
3079 instr_out(data, hw_offset, 3, "scratch offset\n");
3080 instr_out(data, hw_offset, 4,
3081 "Dispatch GRF start %d, VUE read length %d, "
3082 "VUE read offset %d\n", (data[4] >> 20) & 0x1f,
3083 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3084 instr_out(data, hw_offset, 5,
3085 "Max Threads %d, Vertex Cache %sable, "
3086 "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1,
3087 (data[5] & (1 << 1)) != 0 ? "dis" : "en",
3088 (data[5] & 1) != 0 ? "en" : "dis");
3092 len = (data[0] & 0xff) + 2;
3094 fprintf(out, "Bad count in 3DSTATE_GS\n");
3096 BUFFER_FAIL(count, len, "3DSTATE_GS");
3097 instr_out(data, hw_offset, 0, "3DSTATE_GS\n");
3098 instr_out(data, hw_offset, 1, "kernel pointer\n");
3099 instr_out(data, hw_offset, 2,
3100 "SPF=%d, VME=%d, Sampler Count %d, "
3101 "Binding table count %d\n", (data[2] >> 31) & 1,
3102 (data[2] >> 30) & 1, (data[2] >> 27) & 7,
3103 (data[2] >> 18) & 0xff);
3104 instr_out(data, hw_offset, 3, "scratch offset\n");
3105 instr_out(data, hw_offset, 4,
3106 "Dispatch GRF start %d, VUE read length %d, "
3107 "VUE read offset %d\n", (data[4] & 0xf),
3108 (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f);
3109 instr_out(data, hw_offset, 5,
3110 "Max Threads %d, Rendering %sable\n",
3111 ((data[5] >> 25) & 0x7f) + 1,
3112 (data[5] & (1 << 8)) != 0 ? "en" : "dis");
3113 instr_out(data, hw_offset, 6,
3114 "Reorder %sable, Discard Adjaceny %sable, "
3116 (data[6] & (1 << 30)) != 0 ? "en" : "dis",
3117 (data[6] & (1 << 29)) != 0 ? "en" : "dis",
3118 (data[6] & (1 << 15)) != 0 ? "en" : "dis");
3122 len = (data[0] & 0xff) + 2;
3124 fprintf(out, "Bad count in 3DSTATE_CLIP\n");
3126 BUFFER_FAIL(count, len, "3DSTATE_CLIP");
3127 instr_out(data, hw_offset, 0, "3DSTATE_CLIP\n");
3128 instr_out(data, hw_offset, 1,
3129 "UserClip distance cull test mask 0x%x\n",
3131 instr_out(data, hw_offset, 2,
3132 "Clip %sable, API mode %s, Viewport XY test %sable, "
3133 "Viewport Z test %sable, Guardband test %sable, Clip mode %d, "
3134 "Perspective Divide %sable, Non-Perspective Barycentric %sable, "
3135 "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n",
3136 (data[2] & (1 << 31)) != 0 ? "en" : "dis",
3137 (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL",
3138 (data[2] & (1 << 28)) != 0 ? "en" : "dis",
3139 (data[2] & (1 << 27)) != 0 ? "en" : "dis",
3140 (data[2] & (1 << 26)) != 0 ? "en" : "dis",
3141 (data[2] >> 13) & 7,
3142 (data[2] & (1 << 9)) != 0 ? "dis" : "en",
3143 (data[2] & (1 << 8)) != 0 ? "en" : "dis",
3144 (data[2] >> 4) & 3, (data[2] >> 2) & 3,
3146 instr_out(data, hw_offset, 3,
3147 "Min PointWidth %d, Max PointWidth %d, "
3148 "Force Zero RTAIndex %sable, Max VPIndex %d\n",
3149 (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff,
3150 (data[3] & (1 << 5)) != 0 ? "en" : "dis",
3155 len = (data[0] & 0xff) + 2;
3157 fprintf(out, "Bad count in 3DSTATE_SF\n");
3159 BUFFER_FAIL(count, len, "3DSTATE_SF");
3160 instr_out(data, hw_offset, 0, "3DSTATE_SF\n");
3161 instr_out(data, hw_offset, 1,
3162 "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, "
3163 "VUE read offset %d\n", (data[1] >> 22) & 0x3f,
3164 (data[1] & (1 << 21)) != 0 ? "en" : "dis",
3165 (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f);
3166 instr_out(data, hw_offset, 2,
3167 "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, "
3168 "VP transform %sable, FrontWinding_%s\n",
3169 (data[2] & (1 << 11)) != 0 ? "en" : "dis",
3170 (data[2] >> 5) & 3, (data[2] >> 3) & 3,
3171 (data[2] & (1 << 1)) != 0 ? "en" : "dis",
3172 (data[2] & 1) != 0 ? "CCW" : "CW");
3173 instr_out(data, hw_offset, 3,
3174 "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n",
3175 (data[3] & (1 << 31)) != 0 ? "en" : "dis",
3176 (data[3] >> 29) & 3,
3177 (data[3] & (1 << 11)) != 0 ? "en" : "dis",
3178 (data[3] >> 8) & 3);
3179 instr_out(data, hw_offset, 4,
3180 "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n",
3181 (data[4] & (1 << 31)) != 0 ? "en" : "dis",
3182 (data[4] & (1 << 12)) != 0 ? 4 : 8,
3183 (data[4] & (1 << 11)) != 0);
3184 instr_out(data, hw_offset, 5,
3185 "Global Depth Offset Constant %f\n",
3186 *(float *)(&data[5]));
3187 instr_out(data, hw_offset, 6, "Global Depth Offset Scale %f\n",
3188 *(float *)(&data[6]));
3189 instr_out(data, hw_offset, 7, "Global Depth Offset Clamp %f\n",
3190 *(float *)(&data[7]));
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");