Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2009-2011 Intel Corporation |
| 3 | * |
| 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: |
| 10 | * |
| 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 |
| 13 | * Software. |
| 14 | * |
| 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 |
| 21 | * IN THE SOFTWARE. |
| 22 | */ |
| 23 | |
Maarten Lankhorst | 07fead4 | 2014-07-31 15:07:27 +0200 | [diff] [blame] | 24 | #ifdef HAVE_CONFIG_H |
| 25 | #include "config.h" |
| 26 | #endif |
| 27 | |
Eric Anholt | 9695eee | 2012-01-04 12:00:59 -0800 | [diff] [blame] | 28 | #include <assert.h> |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 29 | #include <stdint.h> |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 30 | #include <stdlib.h> |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 31 | #include <stdio.h> |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 32 | #include <stdbool.h> |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 33 | #include <stdarg.h> |
| 34 | #include <string.h> |
| 35 | |
Emil Velikov | 42465fe | 2015-04-05 15:51:59 +0100 | [diff] [blame] | 36 | #include "libdrm_macros.h" |
Thierry Reding | 44b08c0 | 2014-01-22 12:06:51 +0100 | [diff] [blame] | 37 | #include "xf86drm.h" |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 38 | #include "intel_chipset.h" |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 39 | #include "intel_bufmgr.h" |
| 40 | |
Emil Velikov | 23667f5 | 2015-08-23 14:20:17 +0100 | [diff] [blame] | 41 | |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 42 | /* Struct for tracking drm_intel_decode state. */ |
| 43 | struct drm_intel_decode { |
Eric Anholt | ea33a23 | 2012-01-03 13:05:57 -0800 | [diff] [blame] | 44 | /** stdio file where the output should land. Defaults to stdout. */ |
| 45 | FILE *out; |
| 46 | |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 47 | /** PCI device ID. */ |
| 48 | uint32_t devid; |
| 49 | |
Eric Anholt | 9695eee | 2012-01-04 12:00:59 -0800 | [diff] [blame] | 50 | /** |
| 51 | * Shorthand device identifier: 3 is 915, 4 is 965, 5 is |
| 52 | * Ironlake, etc. |
| 53 | */ |
| 54 | int gen; |
| 55 | |
Eric Anholt | 8fb66a7 | 2011-12-20 14:59:38 -0800 | [diff] [blame] | 56 | /** GPU address of the start of the current packet. */ |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 57 | uint32_t hw_offset; |
Eric Anholt | 8fb66a7 | 2011-12-20 14:59:38 -0800 | [diff] [blame] | 58 | /** CPU virtual address of the start of the current packet. */ |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 59 | uint32_t *data; |
Eric Anholt | 8fb66a7 | 2011-12-20 14:59:38 -0800 | [diff] [blame] | 60 | /** DWORDs of remaining batchbuffer data starting from the packet. */ |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 61 | uint32_t count; |
| 62 | |
Eric Anholt | 8fb66a7 | 2011-12-20 14:59:38 -0800 | [diff] [blame] | 63 | /** GPU address of the start of the batchbuffer data. */ |
| 64 | uint32_t base_hw_offset; |
| 65 | /** CPU Virtual address of the start of the batchbuffer data. */ |
| 66 | uint32_t *base_data; |
| 67 | /** Number of DWORDs of batchbuffer data. */ |
| 68 | uint32_t base_count; |
| 69 | |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 70 | /** @{ |
| 71 | * GPU head and tail pointers, which will be noted in the dump, or ~0. |
| 72 | */ |
| 73 | uint32_t head, tail; |
| 74 | /** @} */ |
| 75 | |
| 76 | /** |
| 77 | * Whether to dump the dwords after MI_BATCHBUFFER_END. |
| 78 | * |
| 79 | * This sometimes provides clues in corrupted batchbuffers, |
| 80 | * and is used by the intel-gpu-tools. |
| 81 | */ |
| 82 | bool dump_past_end; |
Eric Anholt | 028715e | 2012-01-04 12:31:40 -0800 | [diff] [blame] | 83 | |
| 84 | bool overflowed; |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 85 | }; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 86 | |
| 87 | static FILE *out; |
| 88 | static uint32_t saved_s2 = 0, saved_s4 = 0; |
| 89 | static char saved_s2_set = 0, saved_s4_set = 0; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 90 | static uint32_t head_offset = 0xffffffff; /* undefined */ |
| 91 | static uint32_t tail_offset = 0xffffffff; /* undefined */ |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 92 | |
| 93 | #ifndef ARRAY_SIZE |
| 94 | #define ARRAY_SIZE(A) (sizeof(A)/sizeof(A[0])) |
| 95 | #endif |
| 96 | |
| 97 | #define BUFFER_FAIL(_count, _len, _name) do { \ |
| 98 | fprintf(out, "Buffer size too small in %s (%d < %d)\n", \ |
| 99 | (_name), (_count), (_len)); \ |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 100 | return _count; \ |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 101 | } while (0) |
| 102 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 103 | static float int_as_float(uint32_t intval) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 104 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 105 | union intfloat { |
| 106 | uint32_t i; |
| 107 | float f; |
| 108 | } uval; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 109 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 110 | uval.i = intval; |
| 111 | return uval.f; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 112 | } |
| 113 | |
Thierry Reding | 44b08c0 | 2014-01-22 12:06:51 +0100 | [diff] [blame] | 114 | static void DRM_PRINTFLIKE(3, 4) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 115 | instr_out(struct drm_intel_decode *ctx, unsigned int index, |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 116 | const char *fmt, ...) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 117 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 118 | va_list va; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 119 | const char *parseinfo; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 120 | uint32_t offset = ctx->hw_offset + index * 4; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 121 | |
Eric Anholt | 028715e | 2012-01-04 12:31:40 -0800 | [diff] [blame] | 122 | if (index > ctx->count) { |
| 123 | if (!ctx->overflowed) { |
| 124 | fprintf(out, "ERROR: Decode attempted to continue beyond end of batchbuffer\n"); |
| 125 | ctx->overflowed = true; |
| 126 | } |
| 127 | return; |
| 128 | } |
| 129 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 130 | if (offset == head_offset) |
| 131 | parseinfo = "HEAD"; |
| 132 | else if (offset == tail_offset) |
| 133 | parseinfo = "TAIL"; |
| 134 | else |
| 135 | parseinfo = " "; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 136 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 137 | fprintf(out, "0x%08x: %s 0x%08x: %s", offset, parseinfo, |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 138 | ctx->data[index], index == 0 ? "" : " "); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 139 | va_start(va, fmt); |
| 140 | vfprintf(out, fmt, va); |
| 141 | va_end(va); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | static int |
Ben Widawsky | ee2be4f | 2012-05-27 16:10:51 -0700 | [diff] [blame] | 145 | decode_MI_SET_CONTEXT(struct drm_intel_decode *ctx) |
| 146 | { |
| 147 | uint32_t data = ctx->data[1]; |
| 148 | if (ctx->gen > 7) |
| 149 | return 1; |
| 150 | |
| 151 | instr_out(ctx, 0, "MI_SET_CONTEXT\n"); |
| 152 | instr_out(ctx, 1, "gtt offset = 0x%x%s%s\n", |
| 153 | data & ~0xfff, |
| 154 | data & (1<<1)? ", Force Restore": "", |
| 155 | data & (1<<0)? ", Restore Inhibit": ""); |
| 156 | |
| 157 | return 2; |
| 158 | } |
| 159 | |
| 160 | static int |
Daniel Vetter | 4370425 | 2012-04-02 13:08:09 +0200 | [diff] [blame] | 161 | decode_MI_WAIT_FOR_EVENT(struct drm_intel_decode *ctx) |
| 162 | { |
| 163 | const char *cc_wait; |
| 164 | int cc_shift = 0; |
| 165 | uint32_t data = ctx->data[0]; |
| 166 | |
| 167 | if (ctx->gen <= 5) |
| 168 | cc_shift = 9; |
| 169 | else |
| 170 | cc_shift = 16; |
| 171 | |
| 172 | switch ((data >> cc_shift) & 0x1f) { |
| 173 | case 1: |
| 174 | cc_wait = ", cc wait 1"; |
| 175 | break; |
| 176 | case 2: |
| 177 | cc_wait = ", cc wait 2"; |
| 178 | break; |
| 179 | case 3: |
| 180 | cc_wait = ", cc wait 3"; |
| 181 | break; |
| 182 | case 4: |
| 183 | cc_wait = ", cc wait 4"; |
| 184 | break; |
| 185 | case 5: |
| 186 | cc_wait = ", cc wait 4"; |
| 187 | break; |
| 188 | default: |
| 189 | cc_wait = ""; |
| 190 | break; |
| 191 | } |
| 192 | |
| 193 | if (ctx->gen <= 5) { |
| 194 | instr_out(ctx, 0, "MI_WAIT_FOR_EVENT%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", |
| 195 | data & (1<<18)? ", pipe B start vblank wait": "", |
| 196 | data & (1<<17)? ", pipe A start vblank wait": "", |
| 197 | data & (1<<16)? ", overlay flip pending wait": "", |
| 198 | data & (1<<14)? ", pipe B hblank wait": "", |
| 199 | data & (1<<13)? ", pipe A hblank wait": "", |
| 200 | cc_wait, |
| 201 | data & (1<<8)? ", plane C pending flip wait": "", |
| 202 | data & (1<<7)? ", pipe B vblank wait": "", |
| 203 | data & (1<<6)? ", plane B pending flip wait": "", |
| 204 | data & (1<<5)? ", pipe B scan line wait": "", |
| 205 | data & (1<<4)? ", fbc idle wait": "", |
| 206 | data & (1<<3)? ", pipe A vblank wait": "", |
| 207 | data & (1<<2)? ", plane A pending flip wait": "", |
| 208 | data & (1<<1)? ", plane A scan line wait": ""); |
| 209 | } else { |
| 210 | instr_out(ctx, 0, "MI_WAIT_FOR_EVENT%s%s%s%s%s%s%s%s%s%s%s%s\n", |
| 211 | data & (1<<20)? ", sprite C pending flip wait": "", /* ivb */ |
| 212 | cc_wait, |
| 213 | data & (1<<13)? ", pipe B hblank wait": "", |
| 214 | data & (1<<11)? ", pipe B vblank wait": "", |
| 215 | data & (1<<10)? ", sprite B pending flip wait": "", |
| 216 | data & (1<<9)? ", plane B pending flip wait": "", |
| 217 | data & (1<<8)? ", plane B scan line wait": "", |
| 218 | data & (1<<5)? ", pipe A hblank wait": "", |
| 219 | data & (1<<3)? ", pipe A vblank wait": "", |
| 220 | data & (1<<2)? ", sprite A pending flip wait": "", |
| 221 | data & (1<<1)? ", plane A pending flip wait": "", |
| 222 | data & (1<<0)? ", plane A scan line wait": ""); |
| 223 | } |
| 224 | |
| 225 | return 1; |
| 226 | } |
| 227 | |
| 228 | static int |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 229 | decode_mi(struct drm_intel_decode *ctx) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 230 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 231 | unsigned int opcode, len = -1; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 232 | const char *post_sync_op = ""; |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 233 | uint32_t *data = ctx->data; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 234 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 235 | struct { |
| 236 | uint32_t opcode; |
| 237 | int len_mask; |
Eric Anholt | 07768ba | 2011-12-20 13:46:23 -0800 | [diff] [blame] | 238 | unsigned int min_len; |
| 239 | unsigned int max_len; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 240 | const char *name; |
Daniel Vetter | 4370425 | 2012-04-02 13:08:09 +0200 | [diff] [blame] | 241 | int (*func)(struct drm_intel_decode *ctx); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 242 | } opcodes_mi[] = { |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 243 | { 0x08, 0, 1, 1, "MI_ARB_ON_OFF" }, |
| 244 | { 0x0a, 0, 1, 1, "MI_BATCH_BUFFER_END" }, |
| 245 | { 0x30, 0x3f, 3, 3, "MI_BATCH_BUFFER" }, |
| 246 | { 0x31, 0x3f, 2, 2, "MI_BATCH_BUFFER_START" }, |
| 247 | { 0x14, 0x3f, 3, 3, "MI_DISPLAY_BUFFER_INFO" }, |
| 248 | { 0x04, 0, 1, 1, "MI_FLUSH" }, |
| 249 | { 0x22, 0x1f, 3, 3, "MI_LOAD_REGISTER_IMM" }, |
| 250 | { 0x13, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_EXCL" }, |
| 251 | { 0x12, 0x3f, 2, 2, "MI_LOAD_SCAN_LINES_INCL" }, |
| 252 | { 0x00, 0, 1, 1, "MI_NOOP" }, |
| 253 | { 0x11, 0x3f, 2, 2, "MI_OVERLAY_FLIP" }, |
| 254 | { 0x07, 0, 1, 1, "MI_REPORT_HEAD" }, |
Ben Widawsky | ee2be4f | 2012-05-27 16:10:51 -0700 | [diff] [blame] | 255 | { 0x18, 0x3f, 2, 2, "MI_SET_CONTEXT", decode_MI_SET_CONTEXT }, |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 256 | { 0x20, 0x3f, 3, 4, "MI_STORE_DATA_IMM" }, |
| 257 | { 0x21, 0x3f, 3, 4, "MI_STORE_DATA_INDEX" }, |
| 258 | { 0x24, 0x3f, 3, 3, "MI_STORE_REGISTER_MEM" }, |
| 259 | { 0x02, 0, 1, 1, "MI_USER_INTERRUPT" }, |
Daniel Vetter | 4370425 | 2012-04-02 13:08:09 +0200 | [diff] [blame] | 260 | { 0x03, 0, 1, 1, "MI_WAIT_FOR_EVENT", decode_MI_WAIT_FOR_EVENT }, |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 261 | { 0x16, 0x7f, 3, 3, "MI_SEMAPHORE_MBOX" }, |
| 262 | { 0x26, 0x1f, 3, 4, "MI_FLUSH_DW" }, |
Kenneth Graunke | 551aac4 | 2013-10-29 19:30:45 -0700 | [diff] [blame] | 263 | { 0x28, 0x3f, 3, 3, "MI_REPORT_PERF_COUNT" }, |
Kenneth Graunke | 45810d3 | 2013-10-29 20:41:16 -0700 | [diff] [blame] | 264 | { 0x29, 0xff, 3, 3, "MI_LOAD_REGISTER_MEM" }, |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 265 | { 0x0b, 0, 1, 1, "MI_SUSPEND_FLUSH"}, |
Daniel Vetter | 4370425 | 2012-04-02 13:08:09 +0200 | [diff] [blame] | 266 | }, *opcode_mi = NULL; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 267 | |
| 268 | /* check instruction length */ |
| 269 | for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]); |
| 270 | opcode++) { |
| 271 | if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) { |
| 272 | len = 1; |
| 273 | if (opcodes_mi[opcode].max_len > 1) { |
| 274 | len = |
| 275 | (data[0] & opcodes_mi[opcode].len_mask) + 2; |
| 276 | if (len < opcodes_mi[opcode].min_len |
| 277 | || len > opcodes_mi[opcode].max_len) { |
| 278 | fprintf(out, |
| 279 | "Bad length (%d) in %s, [%d, %d]\n", |
| 280 | len, opcodes_mi[opcode].name, |
| 281 | opcodes_mi[opcode].min_len, |
| 282 | opcodes_mi[opcode].max_len); |
| 283 | } |
| 284 | } |
Daniel Vetter | 4370425 | 2012-04-02 13:08:09 +0200 | [diff] [blame] | 285 | opcode_mi = &opcodes_mi[opcode]; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 286 | break; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 287 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 288 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 289 | |
Daniel Vetter | 4370425 | 2012-04-02 13:08:09 +0200 | [diff] [blame] | 290 | if (opcode_mi && opcode_mi->func) |
| 291 | return opcode_mi->func(ctx); |
| 292 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 293 | switch ((data[0] & 0x1f800000) >> 23) { |
| 294 | case 0x0a: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 295 | instr_out(ctx, 0, "MI_BATCH_BUFFER_END\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 296 | return -1; |
| 297 | case 0x16: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 298 | instr_out(ctx, 0, "MI_SEMAPHORE_MBOX%s%s%s%s %u\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 299 | data[0] & (1 << 22) ? " global gtt," : "", |
| 300 | data[0] & (1 << 21) ? " update semaphore," : "", |
| 301 | data[0] & (1 << 20) ? " compare semaphore," : "", |
| 302 | data[0] & (1 << 18) ? " use compare reg" : "", |
| 303 | (data[0] & (0x3 << 16)) >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 304 | instr_out(ctx, 1, "value\n"); |
| 305 | instr_out(ctx, 2, "address\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 306 | return len; |
| 307 | case 0x21: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 308 | instr_out(ctx, 0, "MI_STORE_DATA_INDEX%s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 309 | data[0] & (1 << 21) ? " use per-process HWS," : ""); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 310 | instr_out(ctx, 1, "index\n"); |
| 311 | instr_out(ctx, 2, "dword\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 312 | if (len == 4) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 313 | instr_out(ctx, 3, "upper dword\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 314 | return len; |
| 315 | case 0x00: |
| 316 | if (data[0] & (1 << 22)) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 317 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 318 | "MI_NOOP write NOPID reg, val=0x%x\n", |
| 319 | data[0] & ((1 << 22) - 1)); |
| 320 | else |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 321 | instr_out(ctx, 0, "MI_NOOP\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 322 | return len; |
| 323 | case 0x26: |
| 324 | switch (data[0] & (0x3 << 14)) { |
| 325 | case (0 << 14): |
| 326 | post_sync_op = "no write"; |
| 327 | break; |
| 328 | case (1 << 14): |
| 329 | post_sync_op = "write data"; |
| 330 | break; |
| 331 | case (2 << 14): |
| 332 | post_sync_op = "reserved"; |
| 333 | break; |
| 334 | case (3 << 14): |
| 335 | post_sync_op = "write TIMESTAMP"; |
| 336 | break; |
| 337 | } |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 338 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 339 | "MI_FLUSH_DW%s%s%s%s post_sync_op='%s' %s%s\n", |
| 340 | data[0] & (1 << 22) ? |
| 341 | " enable protected mem (BCS-only)," : "", |
| 342 | data[0] & (1 << 21) ? " store in hws," : "", |
| 343 | data[0] & (1 << 18) ? " invalidate tlb," : "", |
| 344 | data[0] & (1 << 17) ? " flush gfdt," : "", |
| 345 | post_sync_op, |
| 346 | data[0] & (1 << 8) ? " enable notify interrupt," : "", |
| 347 | data[0] & (1 << 7) ? |
| 348 | " invalidate video state (BCS-only)," : ""); |
| 349 | if (data[0] & (1 << 21)) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 350 | instr_out(ctx, 1, "hws index\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 351 | else |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 352 | instr_out(ctx, 1, "address\n"); |
| 353 | instr_out(ctx, 2, "dword\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 354 | if (len == 4) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 355 | instr_out(ctx, 3, "upper dword\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 356 | return len; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 357 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 358 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 359 | for (opcode = 0; opcode < sizeof(opcodes_mi) / sizeof(opcodes_mi[0]); |
| 360 | opcode++) { |
| 361 | if ((data[0] & 0x1f800000) >> 23 == opcodes_mi[opcode].opcode) { |
Eric Anholt | 07768ba | 2011-12-20 13:46:23 -0800 | [diff] [blame] | 362 | unsigned int i; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 363 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 364 | instr_out(ctx, 0, "%s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 365 | opcodes_mi[opcode].name); |
Eric Anholt | 07768ba | 2011-12-20 13:46:23 -0800 | [diff] [blame] | 366 | for (i = 1; i < len; i++) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 367 | instr_out(ctx, i, "dword %d\n", i); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 368 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 369 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 370 | return len; |
| 371 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 372 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 373 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 374 | instr_out(ctx, 0, "MI UNKNOWN\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 375 | return 1; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | static void |
Eric Anholt | 62b4103 | 2011-12-20 15:17:24 -0800 | [diff] [blame] | 379 | decode_2d_br00(struct drm_intel_decode *ctx, const char *cmd) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 380 | { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 381 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 382 | "%s (rgb %sabled, alpha %sabled, src tile %d, dst tile %d)\n", |
| 383 | cmd, |
Eric Anholt | 62b4103 | 2011-12-20 15:17:24 -0800 | [diff] [blame] | 384 | (ctx->data[0] & (1 << 20)) ? "en" : "dis", |
| 385 | (ctx->data[0] & (1 << 21)) ? "en" : "dis", |
| 386 | (ctx->data[0] >> 15) & 1, |
| 387 | (ctx->data[0] >> 11) & 1); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 388 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 389 | |
Eric Anholt | b037161 | 2011-12-20 15:19:24 -0800 | [diff] [blame] | 390 | static void |
| 391 | decode_2d_br01(struct drm_intel_decode *ctx) |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 392 | { |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 393 | const char *format; |
Eric Anholt | b037161 | 2011-12-20 15:19:24 -0800 | [diff] [blame] | 394 | switch ((ctx->data[1] >> 24) & 0x3) { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 395 | case 0: |
| 396 | format = "8"; |
| 397 | break; |
| 398 | case 1: |
| 399 | format = "565"; |
| 400 | break; |
| 401 | case 2: |
| 402 | format = "1555"; |
| 403 | break; |
| 404 | case 3: |
| 405 | format = "8888"; |
| 406 | break; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 407 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 408 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 409 | instr_out(ctx, 1, |
Eric Anholt | b037161 | 2011-12-20 15:19:24 -0800 | [diff] [blame] | 410 | "format %s, pitch %d, rop 0x%02x, " |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 411 | "clipping %sabled, %s%s \n", |
| 412 | format, |
Eric Anholt | b037161 | 2011-12-20 15:19:24 -0800 | [diff] [blame] | 413 | (short)(ctx->data[1] & 0xffff), |
| 414 | (ctx->data[1] >> 16) & 0xff, |
| 415 | ctx->data[1] & (1 << 30) ? "en" : "dis", |
| 416 | ctx->data[1] & (1 << 31) ? "solid pattern enabled, " : "", |
| 417 | ctx->data[1] & (1 << 31) ? |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 418 | "mono pattern transparency enabled, " : ""); |
| 419 | |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | static int |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 423 | decode_2d(struct drm_intel_decode *ctx) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 424 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 425 | unsigned int opcode, len; |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 426 | uint32_t *data = ctx->data; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 427 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 428 | struct { |
| 429 | uint32_t opcode; |
Eric Anholt | 07768ba | 2011-12-20 13:46:23 -0800 | [diff] [blame] | 430 | unsigned int min_len; |
| 431 | unsigned int max_len; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 432 | const char *name; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 433 | } opcodes_2d[] = { |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 434 | { 0x40, 5, 5, "COLOR_BLT" }, |
| 435 | { 0x43, 6, 6, "SRC_COPY_BLT" }, |
| 436 | { 0x01, 8, 8, "XY_SETUP_BLT" }, |
| 437 | { 0x11, 9, 9, "XY_SETUP_MONO_PATTERN_SL_BLT" }, |
| 438 | { 0x03, 3, 3, "XY_SETUP_CLIP_BLT" }, |
| 439 | { 0x24, 2, 2, "XY_PIXEL_BLT" }, |
| 440 | { 0x25, 3, 3, "XY_SCANLINES_BLT" }, |
| 441 | { 0x26, 4, 4, "Y_TEXT_BLT" }, |
| 442 | { 0x31, 5, 134, "XY_TEXT_IMMEDIATE_BLT" }, |
| 443 | { 0x50, 6, 6, "XY_COLOR_BLT" }, |
| 444 | { 0x51, 6, 6, "XY_PAT_BLT" }, |
| 445 | { 0x76, 8, 8, "XY_PAT_CHROMA_BLT" }, |
| 446 | { 0x72, 7, 135, "XY_PAT_BLT_IMMEDIATE" }, |
| 447 | { 0x77, 9, 137, "XY_PAT_CHROMA_BLT_IMMEDIATE" }, |
| 448 | { 0x52, 9, 9, "XY_MONO_PAT_BLT" }, |
| 449 | { 0x59, 7, 7, "XY_MONO_PAT_FIXED_BLT" }, |
| 450 | { 0x53, 8, 8, "XY_SRC_COPY_BLT" }, |
| 451 | { 0x54, 8, 8, "XY_MONO_SRC_COPY_BLT" }, |
| 452 | { 0x71, 9, 137, "XY_MONO_SRC_COPY_IMMEDIATE_BLT" }, |
| 453 | { 0x55, 9, 9, "XY_FULL_BLT" }, |
| 454 | { 0x55, 9, 137, "XY_FULL_IMMEDIATE_PATTERN_BLT" }, |
| 455 | { 0x56, 9, 9, "XY_FULL_MONO_SRC_BLT" }, |
| 456 | { 0x75, 10, 138, "XY_FULL_MONO_SRC_IMMEDIATE_PATTERN_BLT" }, |
| 457 | { 0x57, 12, 12, "XY_FULL_MONO_PATTERN_BLT" }, |
| 458 | { 0x58, 12, 12, "XY_FULL_MONO_PATTERN_MONO_SRC_BLT"}, |
| 459 | }; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 460 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 461 | switch ((data[0] & 0x1fc00000) >> 22) { |
| 462 | case 0x25: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 463 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 464 | "XY_SCANLINES_BLT (pattern seed (%d, %d), dst tile %d)\n", |
| 465 | (data[0] >> 12) & 0x8, |
| 466 | (data[0] >> 8) & 0x8, (data[0] >> 11) & 1); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 467 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 468 | len = (data[0] & 0x000000ff) + 2; |
| 469 | if (len != 3) |
| 470 | fprintf(out, "Bad count in XY_SCANLINES_BLT\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 471 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 472 | instr_out(ctx, 1, "dest (%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 473 | data[1] & 0xffff, data[1] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 474 | instr_out(ctx, 2, "dest (%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 475 | data[2] & 0xffff, data[2] >> 16); |
| 476 | return len; |
| 477 | case 0x01: |
Eric Anholt | 62b4103 | 2011-12-20 15:17:24 -0800 | [diff] [blame] | 478 | decode_2d_br00(ctx, "XY_SETUP_BLT"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 479 | |
| 480 | len = (data[0] & 0x000000ff) + 2; |
| 481 | if (len != 8) |
| 482 | fprintf(out, "Bad count in XY_SETUP_BLT\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 483 | |
Eric Anholt | b037161 | 2011-12-20 15:19:24 -0800 | [diff] [blame] | 484 | decode_2d_br01(ctx); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 485 | instr_out(ctx, 2, "cliprect (%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 486 | data[2] & 0xffff, data[2] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 487 | instr_out(ctx, 3, "cliprect (%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 488 | data[3] & 0xffff, data[3] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 489 | instr_out(ctx, 4, "setup dst offset 0x%08x\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 490 | data[4]); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 491 | instr_out(ctx, 5, "setup background color\n"); |
| 492 | instr_out(ctx, 6, "setup foreground color\n"); |
| 493 | instr_out(ctx, 7, "color pattern offset\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 494 | return len; |
| 495 | case 0x03: |
Eric Anholt | 62b4103 | 2011-12-20 15:17:24 -0800 | [diff] [blame] | 496 | decode_2d_br00(ctx, "XY_SETUP_CLIP_BLT"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 497 | |
| 498 | len = (data[0] & 0x000000ff) + 2; |
| 499 | if (len != 3) |
| 500 | fprintf(out, "Bad count in XY_SETUP_CLIP_BLT\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 501 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 502 | instr_out(ctx, 1, "cliprect (%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 503 | data[1] & 0xffff, data[2] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 504 | instr_out(ctx, 2, "cliprect (%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 505 | data[2] & 0xffff, data[3] >> 16); |
| 506 | return len; |
| 507 | case 0x11: |
Eric Anholt | 62b4103 | 2011-12-20 15:17:24 -0800 | [diff] [blame] | 508 | decode_2d_br00(ctx, "XY_SETUP_MONO_PATTERN_SL_BLT"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 509 | |
| 510 | len = (data[0] & 0x000000ff) + 2; |
| 511 | if (len != 9) |
| 512 | fprintf(out, |
| 513 | "Bad count in XY_SETUP_MONO_PATTERN_SL_BLT\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 514 | |
Eric Anholt | b037161 | 2011-12-20 15:19:24 -0800 | [diff] [blame] | 515 | decode_2d_br01(ctx); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 516 | instr_out(ctx, 2, "cliprect (%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 517 | data[2] & 0xffff, data[2] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 518 | instr_out(ctx, 3, "cliprect (%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 519 | data[3] & 0xffff, data[3] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 520 | instr_out(ctx, 4, "setup dst offset 0x%08x\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 521 | data[4]); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 522 | instr_out(ctx, 5, "setup background color\n"); |
| 523 | instr_out(ctx, 6, "setup foreground color\n"); |
| 524 | instr_out(ctx, 7, "mono pattern dw0\n"); |
| 525 | instr_out(ctx, 8, "mono pattern dw1\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 526 | return len; |
| 527 | case 0x50: |
Eric Anholt | 62b4103 | 2011-12-20 15:17:24 -0800 | [diff] [blame] | 528 | decode_2d_br00(ctx, "XY_COLOR_BLT"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 529 | |
| 530 | len = (data[0] & 0x000000ff) + 2; |
| 531 | if (len != 6) |
| 532 | fprintf(out, "Bad count in XY_COLOR_BLT\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 533 | |
Eric Anholt | b037161 | 2011-12-20 15:19:24 -0800 | [diff] [blame] | 534 | decode_2d_br01(ctx); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 535 | instr_out(ctx, 2, "(%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 536 | data[2] & 0xffff, data[2] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 537 | instr_out(ctx, 3, "(%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 538 | data[3] & 0xffff, data[3] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 539 | instr_out(ctx, 4, "offset 0x%08x\n", data[4]); |
| 540 | instr_out(ctx, 5, "color\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 541 | return len; |
| 542 | case 0x53: |
Eric Anholt | 62b4103 | 2011-12-20 15:17:24 -0800 | [diff] [blame] | 543 | decode_2d_br00(ctx, "XY_SRC_COPY_BLT"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 544 | |
| 545 | len = (data[0] & 0x000000ff) + 2; |
| 546 | if (len != 8) |
| 547 | fprintf(out, "Bad count in XY_SRC_COPY_BLT\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 548 | |
Eric Anholt | b037161 | 2011-12-20 15:19:24 -0800 | [diff] [blame] | 549 | decode_2d_br01(ctx); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 550 | instr_out(ctx, 2, "dst (%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 551 | data[2] & 0xffff, data[2] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 552 | instr_out(ctx, 3, "dst (%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 553 | data[3] & 0xffff, data[3] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 554 | instr_out(ctx, 4, "dst offset 0x%08x\n", data[4]); |
| 555 | instr_out(ctx, 5, "src (%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 556 | data[5] & 0xffff, data[5] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 557 | instr_out(ctx, 6, "src pitch %d\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 558 | (short)(data[6] & 0xffff)); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 559 | instr_out(ctx, 7, "src offset 0x%08x\n", data[7]); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 560 | return len; |
| 561 | } |
| 562 | |
| 563 | for (opcode = 0; opcode < sizeof(opcodes_2d) / sizeof(opcodes_2d[0]); |
| 564 | opcode++) { |
| 565 | if ((data[0] & 0x1fc00000) >> 22 == opcodes_2d[opcode].opcode) { |
| 566 | unsigned int i; |
| 567 | |
| 568 | len = 1; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 569 | instr_out(ctx, 0, "%s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 570 | opcodes_2d[opcode].name); |
| 571 | if (opcodes_2d[opcode].max_len > 1) { |
| 572 | len = (data[0] & 0x000000ff) + 2; |
| 573 | if (len < opcodes_2d[opcode].min_len || |
| 574 | len > opcodes_2d[opcode].max_len) { |
| 575 | fprintf(out, "Bad count in %s\n", |
| 576 | opcodes_2d[opcode].name); |
| 577 | } |
| 578 | } |
| 579 | |
| 580 | for (i = 1; i < len; i++) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 581 | instr_out(ctx, i, "dword %d\n", i); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 582 | } |
| 583 | |
| 584 | return len; |
| 585 | } |
| 586 | } |
| 587 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 588 | instr_out(ctx, 0, "2D UNKNOWN\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 589 | return 1; |
| 590 | } |
| 591 | |
| 592 | static int |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 593 | decode_3d_1c(struct drm_intel_decode *ctx) |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 594 | { |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 595 | uint32_t *data = ctx->data; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 596 | uint32_t opcode; |
| 597 | |
| 598 | opcode = (data[0] & 0x00f80000) >> 19; |
| 599 | |
| 600 | switch (opcode) { |
| 601 | case 0x11: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 602 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 603 | "3DSTATE_DEPTH_SUBRECTANGLE_DISABLE\n"); |
| 604 | return 1; |
| 605 | case 0x10: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 606 | instr_out(ctx, 0, "3DSTATE_SCISSOR_ENABLE %s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 607 | data[0] & 1 ? "enabled" : "disabled"); |
| 608 | return 1; |
| 609 | case 0x01: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 610 | instr_out(ctx, 0, "3DSTATE_MAP_COORD_SET_I830\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 611 | return 1; |
| 612 | case 0x0a: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 613 | instr_out(ctx, 0, "3DSTATE_MAP_CUBE_I830\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 614 | return 1; |
| 615 | case 0x05: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 616 | instr_out(ctx, 0, "3DSTATE_MAP_TEX_STREAM_I830\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 617 | return 1; |
| 618 | } |
| 619 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 620 | instr_out(ctx, 0, "3D UNKNOWN: 3d_1c opcode = 0x%x\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 621 | opcode); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 622 | return 1; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | /** Sets the string dstname to describe the destination of the PS instruction */ |
| 626 | static void |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 627 | i915_get_instruction_dst(uint32_t *data, int i, char *dstname, int do_mask) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 628 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 629 | uint32_t a0 = data[i]; |
| 630 | int dst_nr = (a0 >> 14) & 0xf; |
| 631 | char dstmask[8]; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 632 | const char *sat; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 633 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 634 | if (do_mask) { |
| 635 | if (((a0 >> 10) & 0xf) == 0xf) { |
| 636 | dstmask[0] = 0; |
| 637 | } else { |
| 638 | int dstmask_index = 0; |
| 639 | |
| 640 | dstmask[dstmask_index++] = '.'; |
| 641 | if (a0 & (1 << 10)) |
| 642 | dstmask[dstmask_index++] = 'x'; |
| 643 | if (a0 & (1 << 11)) |
| 644 | dstmask[dstmask_index++] = 'y'; |
| 645 | if (a0 & (1 << 12)) |
| 646 | dstmask[dstmask_index++] = 'z'; |
| 647 | if (a0 & (1 << 13)) |
| 648 | dstmask[dstmask_index++] = 'w'; |
| 649 | dstmask[dstmask_index++] = 0; |
| 650 | } |
| 651 | |
| 652 | if (a0 & (1 << 22)) |
| 653 | sat = ".sat"; |
| 654 | else |
| 655 | sat = ""; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 656 | } else { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 657 | dstmask[0] = 0; |
| 658 | sat = ""; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 659 | } |
| 660 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 661 | switch ((a0 >> 19) & 0x7) { |
| 662 | case 0: |
| 663 | if (dst_nr > 15) |
| 664 | fprintf(out, "bad destination reg R%d\n", dst_nr); |
| 665 | sprintf(dstname, "R%d%s%s", dst_nr, dstmask, sat); |
| 666 | break; |
| 667 | case 4: |
| 668 | if (dst_nr > 0) |
| 669 | fprintf(out, "bad destination reg oC%d\n", dst_nr); |
| 670 | sprintf(dstname, "oC%s%s", dstmask, sat); |
| 671 | break; |
| 672 | case 5: |
| 673 | if (dst_nr > 0) |
| 674 | fprintf(out, "bad destination reg oD%d\n", dst_nr); |
| 675 | sprintf(dstname, "oD%s%s", dstmask, sat); |
| 676 | break; |
| 677 | case 6: |
| 678 | if (dst_nr > 3) |
| 679 | fprintf(out, "bad destination reg U%d\n", dst_nr); |
| 680 | sprintf(dstname, "U%d%s%s", dst_nr, dstmask, sat); |
| 681 | break; |
| 682 | default: |
| 683 | sprintf(dstname, "RESERVED"); |
| 684 | break; |
| 685 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 686 | } |
| 687 | |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 688 | static const char * |
| 689 | i915_get_channel_swizzle(uint32_t select) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 690 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 691 | switch (select & 0x7) { |
| 692 | case 0: |
| 693 | return (select & 8) ? "-x" : "x"; |
| 694 | case 1: |
| 695 | return (select & 8) ? "-y" : "y"; |
| 696 | case 2: |
| 697 | return (select & 8) ? "-z" : "z"; |
| 698 | case 3: |
| 699 | return (select & 8) ? "-w" : "w"; |
| 700 | case 4: |
| 701 | return (select & 8) ? "-0" : "0"; |
| 702 | case 5: |
| 703 | return (select & 8) ? "-1" : "1"; |
| 704 | default: |
| 705 | return (select & 8) ? "-bad" : "bad"; |
| 706 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 707 | } |
| 708 | |
| 709 | static void |
| 710 | i915_get_instruction_src_name(uint32_t src_type, uint32_t src_nr, char *name) |
| 711 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 712 | switch (src_type) { |
| 713 | case 0: |
| 714 | sprintf(name, "R%d", src_nr); |
| 715 | if (src_nr > 15) |
| 716 | fprintf(out, "bad src reg %s\n", name); |
| 717 | break; |
| 718 | case 1: |
| 719 | if (src_nr < 8) |
| 720 | sprintf(name, "T%d", src_nr); |
| 721 | else if (src_nr == 8) |
| 722 | sprintf(name, "DIFFUSE"); |
| 723 | else if (src_nr == 9) |
| 724 | sprintf(name, "SPECULAR"); |
| 725 | else if (src_nr == 10) |
| 726 | sprintf(name, "FOG"); |
| 727 | else { |
| 728 | fprintf(out, "bad src reg T%d\n", src_nr); |
| 729 | sprintf(name, "RESERVED"); |
| 730 | } |
| 731 | break; |
| 732 | case 2: |
| 733 | sprintf(name, "C%d", src_nr); |
| 734 | if (src_nr > 31) |
| 735 | fprintf(out, "bad src reg %s\n", name); |
| 736 | break; |
| 737 | case 4: |
| 738 | sprintf(name, "oC"); |
| 739 | if (src_nr > 0) |
| 740 | fprintf(out, "bad src reg oC%d\n", src_nr); |
| 741 | break; |
| 742 | case 5: |
| 743 | sprintf(name, "oD"); |
| 744 | if (src_nr > 0) |
| 745 | fprintf(out, "bad src reg oD%d\n", src_nr); |
| 746 | break; |
| 747 | case 6: |
| 748 | sprintf(name, "U%d", src_nr); |
| 749 | if (src_nr > 3) |
| 750 | fprintf(out, "bad src reg %s\n", name); |
| 751 | break; |
| 752 | default: |
| 753 | fprintf(out, "bad src reg type %d\n", src_type); |
| 754 | sprintf(name, "RESERVED"); |
| 755 | break; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 756 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 757 | } |
| 758 | |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 759 | static void i915_get_instruction_src0(uint32_t *data, int i, char *srcname) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 760 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 761 | uint32_t a0 = data[i]; |
| 762 | uint32_t a1 = data[i + 1]; |
| 763 | int src_nr = (a0 >> 2) & 0x1f; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 764 | const char *swizzle_x = i915_get_channel_swizzle((a1 >> 28) & 0xf); |
| 765 | const char *swizzle_y = i915_get_channel_swizzle((a1 >> 24) & 0xf); |
| 766 | const char *swizzle_z = i915_get_channel_swizzle((a1 >> 20) & 0xf); |
| 767 | const char *swizzle_w = i915_get_channel_swizzle((a1 >> 16) & 0xf); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 768 | char swizzle[100]; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 769 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 770 | i915_get_instruction_src_name((a0 >> 7) & 0x7, src_nr, srcname); |
| 771 | sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, |
| 772 | swizzle_w); |
| 773 | if (strcmp(swizzle, ".xyzw") != 0) |
| 774 | strcat(srcname, swizzle); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 775 | } |
| 776 | |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 777 | static void i915_get_instruction_src1(uint32_t *data, int i, char *srcname) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 778 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 779 | uint32_t a1 = data[i + 1]; |
| 780 | uint32_t a2 = data[i + 2]; |
| 781 | int src_nr = (a1 >> 8) & 0x1f; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 782 | const char *swizzle_x = i915_get_channel_swizzle((a1 >> 4) & 0xf); |
| 783 | const char *swizzle_y = i915_get_channel_swizzle((a1 >> 0) & 0xf); |
| 784 | const char *swizzle_z = i915_get_channel_swizzle((a2 >> 28) & 0xf); |
| 785 | const char *swizzle_w = i915_get_channel_swizzle((a2 >> 24) & 0xf); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 786 | char swizzle[100]; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 787 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 788 | i915_get_instruction_src_name((a1 >> 13) & 0x7, src_nr, srcname); |
| 789 | sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, |
| 790 | swizzle_w); |
| 791 | if (strcmp(swizzle, ".xyzw") != 0) |
| 792 | strcat(srcname, swizzle); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 793 | } |
| 794 | |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 795 | static void i915_get_instruction_src2(uint32_t *data, int i, char *srcname) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 796 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 797 | uint32_t a2 = data[i + 2]; |
| 798 | int src_nr = (a2 >> 16) & 0x1f; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 799 | const char *swizzle_x = i915_get_channel_swizzle((a2 >> 12) & 0xf); |
| 800 | const char *swizzle_y = i915_get_channel_swizzle((a2 >> 8) & 0xf); |
| 801 | const char *swizzle_z = i915_get_channel_swizzle((a2 >> 4) & 0xf); |
| 802 | const char *swizzle_w = i915_get_channel_swizzle((a2 >> 0) & 0xf); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 803 | char swizzle[100]; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 804 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 805 | i915_get_instruction_src_name((a2 >> 21) & 0x7, src_nr, srcname); |
| 806 | sprintf(swizzle, ".%s%s%s%s", swizzle_x, swizzle_y, swizzle_z, |
| 807 | swizzle_w); |
| 808 | if (strcmp(swizzle, ".xyzw") != 0) |
| 809 | strcat(srcname, swizzle); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 810 | } |
| 811 | |
| 812 | static void |
| 813 | i915_get_instruction_addr(uint32_t src_type, uint32_t src_nr, char *name) |
| 814 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 815 | switch (src_type) { |
| 816 | case 0: |
| 817 | sprintf(name, "R%d", src_nr); |
| 818 | if (src_nr > 15) |
| 819 | fprintf(out, "bad src reg %s\n", name); |
| 820 | break; |
| 821 | case 1: |
| 822 | if (src_nr < 8) |
| 823 | sprintf(name, "T%d", src_nr); |
| 824 | else if (src_nr == 8) |
| 825 | sprintf(name, "DIFFUSE"); |
| 826 | else if (src_nr == 9) |
| 827 | sprintf(name, "SPECULAR"); |
| 828 | else if (src_nr == 10) |
| 829 | sprintf(name, "FOG"); |
| 830 | else { |
| 831 | fprintf(out, "bad src reg T%d\n", src_nr); |
| 832 | sprintf(name, "RESERVED"); |
| 833 | } |
| 834 | break; |
| 835 | case 4: |
| 836 | sprintf(name, "oC"); |
| 837 | if (src_nr > 0) |
| 838 | fprintf(out, "bad src reg oC%d\n", src_nr); |
| 839 | break; |
| 840 | case 5: |
| 841 | sprintf(name, "oD"); |
| 842 | if (src_nr > 0) |
| 843 | fprintf(out, "bad src reg oD%d\n", src_nr); |
| 844 | break; |
| 845 | default: |
| 846 | fprintf(out, "bad src reg type %d\n", src_type); |
| 847 | sprintf(name, "RESERVED"); |
| 848 | break; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 849 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | static void |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 853 | i915_decode_alu1(struct drm_intel_decode *ctx, |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 854 | int i, char *instr_prefix, const char *op_name) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 855 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 856 | char dst[100], src0[100]; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 857 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 858 | i915_get_instruction_dst(ctx->data, i, dst, 1); |
| 859 | i915_get_instruction_src0(ctx->data, i, src0); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 860 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 861 | instr_out(ctx, i++, "%s: %s %s, %s\n", instr_prefix, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 862 | op_name, dst, src0); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 863 | instr_out(ctx, i++, "%s\n", instr_prefix); |
| 864 | instr_out(ctx, i++, "%s\n", instr_prefix); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 865 | } |
| 866 | |
| 867 | static void |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 868 | i915_decode_alu2(struct drm_intel_decode *ctx, |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 869 | int i, char *instr_prefix, const char *op_name) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 870 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 871 | char dst[100], src0[100], src1[100]; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 872 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 873 | i915_get_instruction_dst(ctx->data, i, dst, 1); |
| 874 | i915_get_instruction_src0(ctx->data, i, src0); |
| 875 | i915_get_instruction_src1(ctx->data, i, src1); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 876 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 877 | instr_out(ctx, i++, "%s: %s %s, %s, %s\n", instr_prefix, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 878 | op_name, dst, src0, src1); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 879 | instr_out(ctx, i++, "%s\n", instr_prefix); |
| 880 | instr_out(ctx, i++, "%s\n", instr_prefix); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 881 | } |
| 882 | |
| 883 | static void |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 884 | i915_decode_alu3(struct drm_intel_decode *ctx, |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 885 | int i, char *instr_prefix, const char *op_name) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 886 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 887 | char dst[100], src0[100], src1[100], src2[100]; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 888 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 889 | i915_get_instruction_dst(ctx->data, i, dst, 1); |
| 890 | i915_get_instruction_src0(ctx->data, i, src0); |
| 891 | i915_get_instruction_src1(ctx->data, i, src1); |
| 892 | i915_get_instruction_src2(ctx->data, i, src2); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 893 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 894 | instr_out(ctx, i++, "%s: %s %s, %s, %s, %s\n", instr_prefix, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 895 | op_name, dst, src0, src1, src2); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 896 | instr_out(ctx, i++, "%s\n", instr_prefix); |
| 897 | instr_out(ctx, i++, "%s\n", instr_prefix); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 898 | } |
| 899 | |
| 900 | static void |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 901 | i915_decode_tex(struct drm_intel_decode *ctx, int i, |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 902 | const char *instr_prefix, const char *tex_name) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 903 | { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 904 | uint32_t t0 = ctx->data[i]; |
| 905 | uint32_t t1 = ctx->data[i + 1]; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 906 | char dst_name[100]; |
| 907 | char addr_name[100]; |
| 908 | int sampler_nr; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 909 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 910 | i915_get_instruction_dst(ctx->data, i, dst_name, 0); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 911 | i915_get_instruction_addr((t1 >> 24) & 0x7, |
| 912 | (t1 >> 17) & 0xf, addr_name); |
| 913 | sampler_nr = t0 & 0xf; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 914 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 915 | instr_out(ctx, i++, "%s: %s %s, S%d, %s\n", instr_prefix, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 916 | tex_name, dst_name, sampler_nr, addr_name); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 917 | instr_out(ctx, i++, "%s\n", instr_prefix); |
| 918 | instr_out(ctx, i++, "%s\n", instr_prefix); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 919 | } |
| 920 | |
| 921 | static void |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 922 | i915_decode_dcl(struct drm_intel_decode *ctx, int i, char *instr_prefix) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 923 | { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 924 | uint32_t d0 = ctx->data[i]; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 925 | const char *sampletype; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 926 | int dcl_nr = (d0 >> 14) & 0xf; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 927 | const char *dcl_x = d0 & (1 << 10) ? "x" : ""; |
| 928 | const char *dcl_y = d0 & (1 << 11) ? "y" : ""; |
| 929 | const char *dcl_z = d0 & (1 << 12) ? "z" : ""; |
| 930 | const char *dcl_w = d0 & (1 << 13) ? "w" : ""; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 931 | char dcl_mask[10]; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 932 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 933 | switch ((d0 >> 19) & 0x3) { |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 934 | case 1: |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 935 | sprintf(dcl_mask, ".%s%s%s%s", dcl_x, dcl_y, dcl_z, dcl_w); |
| 936 | if (strcmp(dcl_mask, ".") == 0) |
| 937 | fprintf(out, "bad (empty) dcl mask\n"); |
| 938 | |
| 939 | if (dcl_nr > 10) |
| 940 | fprintf(out, "bad T%d dcl register number\n", dcl_nr); |
| 941 | if (dcl_nr < 8) { |
| 942 | if (strcmp(dcl_mask, ".x") != 0 && |
| 943 | strcmp(dcl_mask, ".xy") != 0 && |
| 944 | strcmp(dcl_mask, ".xz") != 0 && |
| 945 | strcmp(dcl_mask, ".w") != 0 && |
| 946 | strcmp(dcl_mask, ".xyzw") != 0) { |
| 947 | fprintf(out, "bad T%d.%s dcl mask\n", dcl_nr, |
| 948 | dcl_mask); |
| 949 | } |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 950 | instr_out(ctx, i++, "%s: DCL T%d%s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 951 | instr_prefix, dcl_nr, dcl_mask); |
| 952 | } else { |
| 953 | if (strcmp(dcl_mask, ".xz") == 0) |
| 954 | fprintf(out, "errataed bad dcl mask %s\n", |
| 955 | dcl_mask); |
| 956 | else if (strcmp(dcl_mask, ".xw") == 0) |
| 957 | fprintf(out, "errataed bad dcl mask %s\n", |
| 958 | dcl_mask); |
| 959 | else if (strcmp(dcl_mask, ".xzw") == 0) |
| 960 | fprintf(out, "errataed bad dcl mask %s\n", |
| 961 | dcl_mask); |
| 962 | |
| 963 | if (dcl_nr == 8) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 964 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 965 | "%s: DCL DIFFUSE%s\n", instr_prefix, |
| 966 | dcl_mask); |
| 967 | } else if (dcl_nr == 9) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 968 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 969 | "%s: DCL SPECULAR%s\n", instr_prefix, |
| 970 | dcl_mask); |
| 971 | } else if (dcl_nr == 10) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 972 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 973 | "%s: DCL FOG%s\n", instr_prefix, |
| 974 | dcl_mask); |
| 975 | } |
| 976 | } |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 977 | instr_out(ctx, i++, "%s\n", instr_prefix); |
| 978 | instr_out(ctx, i++, "%s\n", instr_prefix); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 979 | break; |
| 980 | case 3: |
| 981 | switch ((d0 >> 22) & 0x3) { |
| 982 | case 0: |
| 983 | sampletype = "2D"; |
| 984 | break; |
| 985 | case 1: |
| 986 | sampletype = "CUBE"; |
| 987 | break; |
| 988 | case 2: |
| 989 | sampletype = "3D"; |
| 990 | break; |
| 991 | default: |
| 992 | sampletype = "RESERVED"; |
| 993 | break; |
| 994 | } |
| 995 | if (dcl_nr > 15) |
| 996 | fprintf(out, "bad S%d dcl register number\n", dcl_nr); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 997 | instr_out(ctx, i++, "%s: DCL S%d %s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 998 | instr_prefix, dcl_nr, sampletype); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 999 | instr_out(ctx, i++, "%s\n", instr_prefix); |
| 1000 | instr_out(ctx, i++, "%s\n", instr_prefix); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1001 | break; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1002 | default: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1003 | instr_out(ctx, i++, "%s: DCL RESERVED%d\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1004 | instr_prefix, dcl_nr); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1005 | instr_out(ctx, i++, "%s\n", instr_prefix); |
| 1006 | instr_out(ctx, i++, "%s\n", instr_prefix); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1007 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1008 | } |
| 1009 | |
| 1010 | static void |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1011 | i915_decode_instruction(struct drm_intel_decode *ctx, |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1012 | int i, char *instr_prefix) |
| 1013 | { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1014 | switch ((ctx->data[i] >> 24) & 0x1f) { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1015 | case 0x0: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1016 | instr_out(ctx, i++, "%s: NOP\n", instr_prefix); |
| 1017 | instr_out(ctx, i++, "%s\n", instr_prefix); |
| 1018 | instr_out(ctx, i++, "%s\n", instr_prefix); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1019 | break; |
| 1020 | case 0x01: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1021 | i915_decode_alu2(ctx, i, instr_prefix, "ADD"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1022 | break; |
| 1023 | case 0x02: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1024 | i915_decode_alu1(ctx, i, instr_prefix, "MOV"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1025 | break; |
| 1026 | case 0x03: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1027 | i915_decode_alu2(ctx, i, instr_prefix, "MUL"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1028 | break; |
| 1029 | case 0x04: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1030 | i915_decode_alu3(ctx, i, instr_prefix, "MAD"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1031 | break; |
| 1032 | case 0x05: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1033 | i915_decode_alu3(ctx, i, instr_prefix, "DP2ADD"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1034 | break; |
| 1035 | case 0x06: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1036 | i915_decode_alu2(ctx, i, instr_prefix, "DP3"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1037 | break; |
| 1038 | case 0x07: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1039 | i915_decode_alu2(ctx, i, instr_prefix, "DP4"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1040 | break; |
| 1041 | case 0x08: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1042 | i915_decode_alu1(ctx, i, instr_prefix, "FRC"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1043 | break; |
| 1044 | case 0x09: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1045 | i915_decode_alu1(ctx, i, instr_prefix, "RCP"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1046 | break; |
| 1047 | case 0x0a: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1048 | i915_decode_alu1(ctx, i, instr_prefix, "RSQ"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1049 | break; |
| 1050 | case 0x0b: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1051 | i915_decode_alu1(ctx, i, instr_prefix, "EXP"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1052 | break; |
| 1053 | case 0x0c: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1054 | i915_decode_alu1(ctx, i, instr_prefix, "LOG"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1055 | break; |
| 1056 | case 0x0d: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1057 | i915_decode_alu2(ctx, i, instr_prefix, "CMP"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1058 | break; |
| 1059 | case 0x0e: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1060 | i915_decode_alu2(ctx, i, instr_prefix, "MIN"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1061 | break; |
| 1062 | case 0x0f: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1063 | i915_decode_alu2(ctx, i, instr_prefix, "MAX"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1064 | break; |
| 1065 | case 0x10: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1066 | i915_decode_alu1(ctx, i, instr_prefix, "FLR"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1067 | break; |
| 1068 | case 0x11: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1069 | i915_decode_alu1(ctx, i, instr_prefix, "MOD"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1070 | break; |
| 1071 | case 0x12: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1072 | i915_decode_alu1(ctx, i, instr_prefix, "TRC"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1073 | break; |
| 1074 | case 0x13: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1075 | i915_decode_alu2(ctx, i, instr_prefix, "SGE"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1076 | break; |
| 1077 | case 0x14: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1078 | i915_decode_alu2(ctx, i, instr_prefix, "SLT"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1079 | break; |
| 1080 | case 0x15: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1081 | i915_decode_tex(ctx, i, instr_prefix, "TEXLD"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1082 | break; |
| 1083 | case 0x16: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1084 | i915_decode_tex(ctx, i, instr_prefix, "TEXLDP"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1085 | break; |
| 1086 | case 0x17: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1087 | i915_decode_tex(ctx, i, instr_prefix, "TEXLDB"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1088 | break; |
| 1089 | case 0x19: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1090 | i915_decode_dcl(ctx, i, instr_prefix); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1091 | break; |
| 1092 | default: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1093 | instr_out(ctx, i++, "%s: unknown\n", instr_prefix); |
| 1094 | instr_out(ctx, i++, "%s\n", instr_prefix); |
| 1095 | instr_out(ctx, i++, "%s\n", instr_prefix); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1096 | break; |
| 1097 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1098 | } |
| 1099 | |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 1100 | static const char * |
| 1101 | decode_compare_func(uint32_t op) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1102 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1103 | switch (op & 0x7) { |
| 1104 | case 0: |
| 1105 | return "always"; |
| 1106 | case 1: |
| 1107 | return "never"; |
| 1108 | case 2: |
| 1109 | return "less"; |
| 1110 | case 3: |
| 1111 | return "equal"; |
| 1112 | case 4: |
| 1113 | return "lequal"; |
| 1114 | case 5: |
| 1115 | return "greater"; |
| 1116 | case 6: |
| 1117 | return "notequal"; |
| 1118 | case 7: |
| 1119 | return "gequal"; |
| 1120 | } |
| 1121 | return ""; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1122 | } |
| 1123 | |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 1124 | static const char * |
| 1125 | decode_stencil_op(uint32_t op) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1126 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1127 | switch (op & 0x7) { |
| 1128 | case 0: |
| 1129 | return "keep"; |
| 1130 | case 1: |
| 1131 | return "zero"; |
| 1132 | case 2: |
| 1133 | return "replace"; |
| 1134 | case 3: |
| 1135 | return "incr_sat"; |
| 1136 | case 4: |
| 1137 | return "decr_sat"; |
| 1138 | case 5: |
| 1139 | return "greater"; |
| 1140 | case 6: |
| 1141 | return "incr"; |
| 1142 | case 7: |
| 1143 | return "decr"; |
| 1144 | } |
| 1145 | return ""; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1146 | } |
| 1147 | |
Eric Anholt | 4149faf | 2011-12-20 14:32:27 -0800 | [diff] [blame] | 1148 | #if 0 |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 1149 | static const char * |
| 1150 | decode_logic_op(uint32_t op) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1151 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1152 | switch (op & 0xf) { |
| 1153 | case 0: |
| 1154 | return "clear"; |
| 1155 | case 1: |
| 1156 | return "nor"; |
| 1157 | case 2: |
| 1158 | return "and_inv"; |
| 1159 | case 3: |
| 1160 | return "copy_inv"; |
| 1161 | case 4: |
| 1162 | return "and_rvrse"; |
| 1163 | case 5: |
| 1164 | return "inv"; |
| 1165 | case 6: |
| 1166 | return "xor"; |
| 1167 | case 7: |
| 1168 | return "nand"; |
| 1169 | case 8: |
| 1170 | return "and"; |
| 1171 | case 9: |
| 1172 | return "equiv"; |
| 1173 | case 10: |
| 1174 | return "noop"; |
| 1175 | case 11: |
| 1176 | return "or_inv"; |
| 1177 | case 12: |
| 1178 | return "copy"; |
| 1179 | case 13: |
| 1180 | return "or_rvrse"; |
| 1181 | case 14: |
| 1182 | return "or"; |
| 1183 | case 15: |
| 1184 | return "set"; |
| 1185 | } |
| 1186 | return ""; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1187 | } |
Eric Anholt | 4149faf | 2011-12-20 14:32:27 -0800 | [diff] [blame] | 1188 | #endif |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1189 | |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 1190 | static const char * |
| 1191 | decode_blend_fact(uint32_t op) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1192 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1193 | switch (op & 0xf) { |
| 1194 | case 1: |
| 1195 | return "zero"; |
| 1196 | case 2: |
| 1197 | return "one"; |
| 1198 | case 3: |
| 1199 | return "src_colr"; |
| 1200 | case 4: |
| 1201 | return "inv_src_colr"; |
| 1202 | case 5: |
| 1203 | return "src_alpha"; |
| 1204 | case 6: |
| 1205 | return "inv_src_alpha"; |
| 1206 | case 7: |
| 1207 | return "dst_alpha"; |
| 1208 | case 8: |
| 1209 | return "inv_dst_alpha"; |
| 1210 | case 9: |
| 1211 | return "dst_colr"; |
| 1212 | case 10: |
| 1213 | return "inv_dst_colr"; |
| 1214 | case 11: |
| 1215 | return "src_alpha_sat"; |
| 1216 | case 12: |
| 1217 | return "cnst_colr"; |
| 1218 | case 13: |
| 1219 | return "inv_cnst_colr"; |
| 1220 | case 14: |
| 1221 | return "cnst_alpha"; |
| 1222 | case 15: |
| 1223 | return "inv_const_alpha"; |
| 1224 | } |
| 1225 | return ""; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1226 | } |
| 1227 | |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 1228 | static const char * |
| 1229 | decode_tex_coord_mode(uint32_t mode) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1230 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1231 | switch (mode & 0x7) { |
| 1232 | case 0: |
| 1233 | return "wrap"; |
| 1234 | case 1: |
| 1235 | return "mirror"; |
| 1236 | case 2: |
| 1237 | return "clamp_edge"; |
| 1238 | case 3: |
| 1239 | return "cube"; |
| 1240 | case 4: |
| 1241 | return "clamp_border"; |
| 1242 | case 5: |
| 1243 | return "mirror_once"; |
| 1244 | } |
| 1245 | return ""; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1246 | } |
| 1247 | |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 1248 | static const char * |
| 1249 | decode_sample_filter(uint32_t mode) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1250 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1251 | switch (mode & 0x7) { |
| 1252 | case 0: |
| 1253 | return "nearest"; |
| 1254 | case 1: |
| 1255 | return "linear"; |
| 1256 | case 2: |
| 1257 | return "anisotropic"; |
| 1258 | case 3: |
| 1259 | return "4x4_1"; |
| 1260 | case 4: |
| 1261 | return "4x4_2"; |
| 1262 | case 5: |
| 1263 | return "4x4_flat"; |
| 1264 | case 6: |
| 1265 | return "6x5_mono"; |
| 1266 | } |
| 1267 | return ""; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1268 | } |
| 1269 | |
| 1270 | static int |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 1271 | decode_3d_1d(struct drm_intel_decode *ctx) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1272 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1273 | unsigned int len, i, c, idx, word, map, sampler, instr; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 1274 | const char *format, *zformat, *type; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1275 | uint32_t opcode; |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 1276 | uint32_t *data = ctx->data; |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 1277 | uint32_t devid = ctx->devid; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1278 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1279 | struct { |
| 1280 | uint32_t opcode; |
| 1281 | int i830_only; |
Eric Anholt | 07768ba | 2011-12-20 13:46:23 -0800 | [diff] [blame] | 1282 | unsigned int min_len; |
| 1283 | unsigned int max_len; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 1284 | const char *name; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1285 | } opcodes_3d_1d[] = { |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 1286 | { 0x86, 0, 4, 4, "3DSTATE_CHROMA_KEY" }, |
| 1287 | { 0x88, 0, 2, 2, "3DSTATE_CONSTANT_BLEND_COLOR" }, |
| 1288 | { 0x99, 0, 2, 2, "3DSTATE_DEFAULT_DIFFUSE" }, |
| 1289 | { 0x9a, 0, 2, 2, "3DSTATE_DEFAULT_SPECULAR" }, |
| 1290 | { 0x98, 0, 2, 2, "3DSTATE_DEFAULT_Z" }, |
| 1291 | { 0x97, 0, 2, 2, "3DSTATE_DEPTH_OFFSET_SCALE" }, |
| 1292 | { 0x9d, 0, 65, 65, "3DSTATE_FILTER_COEFFICIENTS_4X4" }, |
| 1293 | { 0x9e, 0, 4, 4, "3DSTATE_MONO_FILTER" }, |
| 1294 | { 0x89, 0, 4, 4, "3DSTATE_FOG_MODE" }, |
| 1295 | { 0x8f, 0, 2, 16, "3DSTATE_MAP_PALLETE_LOAD_32" }, |
| 1296 | { 0x83, 0, 2, 2, "3DSTATE_SPAN_STIPPLE" }, |
| 1297 | { 0x8c, 1, 2, 2, "3DSTATE_MAP_COORD_TRANSFORM_I830" }, |
| 1298 | { 0x8b, 1, 2, 2, "3DSTATE_MAP_VERTEX_TRANSFORM_I830" }, |
| 1299 | { 0x8d, 1, 3, 3, "3DSTATE_W_STATE_I830" }, |
| 1300 | { 0x01, 1, 2, 2, "3DSTATE_COLOR_FACTOR_I830" }, |
| 1301 | { 0x02, 1, 2, 2, "3DSTATE_MAP_COORD_SETBIND_I830"}, |
| 1302 | }, *opcode_3d_1d; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1303 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1304 | opcode = (data[0] & 0x00ff0000) >> 16; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1305 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1306 | switch (opcode) { |
| 1307 | case 0x07: |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 1308 | /* This instruction is unusual. A 0 length means just |
| 1309 | * 1 DWORD instead of 2. The 0 length is specified in |
| 1310 | * one place to be unsupported, but stated to be |
| 1311 | * required in another, and 0 length LOAD_INDIRECTs |
| 1312 | * appear to cause no harm at least. |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1313 | */ |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1314 | instr_out(ctx, 0, "3DSTATE_LOAD_INDIRECT\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1315 | len = (data[0] & 0x000000ff) + 1; |
| 1316 | i = 1; |
| 1317 | if (data[0] & (0x01 << 8)) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1318 | instr_out(ctx, i++, "SIS.0\n"); |
| 1319 | instr_out(ctx, i++, "SIS.1\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1320 | } |
| 1321 | if (data[0] & (0x02 << 8)) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1322 | instr_out(ctx, i++, "DIS.0\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1323 | } |
| 1324 | if (data[0] & (0x04 << 8)) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1325 | instr_out(ctx, i++, "SSB.0\n"); |
| 1326 | instr_out(ctx, i++, "SSB.1\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1327 | } |
| 1328 | if (data[0] & (0x08 << 8)) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1329 | instr_out(ctx, i++, "MSB.0\n"); |
| 1330 | instr_out(ctx, i++, "MSB.1\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1331 | } |
| 1332 | if (data[0] & (0x10 << 8)) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1333 | instr_out(ctx, i++, "PSP.0\n"); |
| 1334 | instr_out(ctx, i++, "PSP.1\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1335 | } |
| 1336 | if (data[0] & (0x20 << 8)) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1337 | instr_out(ctx, i++, "PSC.0\n"); |
| 1338 | instr_out(ctx, i++, "PSC.1\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1339 | } |
| 1340 | if (len != i) { |
| 1341 | fprintf(out, "Bad count in 3DSTATE_LOAD_INDIRECT\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1342 | return len; |
| 1343 | } |
| 1344 | return len; |
| 1345 | case 0x04: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1346 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1347 | "3DSTATE_LOAD_STATE_IMMEDIATE_1\n"); |
| 1348 | len = (data[0] & 0x0000000f) + 2; |
| 1349 | i = 1; |
| 1350 | for (word = 0; word <= 8; word++) { |
| 1351 | if (data[0] & (1 << (4 + word))) { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1352 | /* save vertex state for decode */ |
| 1353 | if (!IS_GEN2(devid)) { |
Eric Anholt | 7b48318 | 2011-12-20 14:27:17 -0800 | [diff] [blame] | 1354 | int tex_num; |
| 1355 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1356 | if (word == 2) { |
| 1357 | saved_s2_set = 1; |
| 1358 | saved_s2 = data[i]; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1359 | } |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1360 | if (word == 4) { |
| 1361 | saved_s4_set = 1; |
| 1362 | saved_s4 = data[i]; |
| 1363 | } |
| 1364 | |
| 1365 | switch (word) { |
| 1366 | case 0: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1367 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1368 | "S0: vbo offset: 0x%08x%s\n", |
| 1369 | data[i] & (~1), |
| 1370 | data[i] & 1 ? |
| 1371 | ", auto cache invalidate disabled" |
| 1372 | : ""); |
| 1373 | break; |
| 1374 | case 1: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1375 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1376 | "S1: vertex width: %i, vertex pitch: %i\n", |
| 1377 | (data[i] >> 24) & |
| 1378 | 0x3f, |
| 1379 | (data[i] >> 16) & |
| 1380 | 0x3f); |
| 1381 | break; |
| 1382 | case 2: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1383 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1384 | "S2: texcoord formats: "); |
Eric Anholt | 7b48318 | 2011-12-20 14:27:17 -0800 | [diff] [blame] | 1385 | for (tex_num = 0; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1386 | tex_num < 8; tex_num++) { |
| 1387 | switch ((data[i] >> |
| 1388 | tex_num * |
| 1389 | 4) & 0xf) { |
| 1390 | case 0: |
| 1391 | fprintf(out, |
| 1392 | "%i=2D ", |
| 1393 | tex_num); |
| 1394 | break; |
| 1395 | case 1: |
| 1396 | fprintf(out, |
| 1397 | "%i=3D ", |
| 1398 | tex_num); |
| 1399 | break; |
| 1400 | case 2: |
| 1401 | fprintf(out, |
| 1402 | "%i=4D ", |
| 1403 | tex_num); |
| 1404 | break; |
| 1405 | case 3: |
| 1406 | fprintf(out, |
| 1407 | "%i=1D ", |
| 1408 | tex_num); |
| 1409 | break; |
| 1410 | case 4: |
| 1411 | fprintf(out, |
| 1412 | "%i=2D_16 ", |
| 1413 | tex_num); |
| 1414 | break; |
| 1415 | case 5: |
| 1416 | fprintf(out, |
| 1417 | "%i=4D_16 ", |
| 1418 | tex_num); |
| 1419 | break; |
| 1420 | case 0xf: |
| 1421 | fprintf(out, |
| 1422 | "%i=NP ", |
| 1423 | tex_num); |
| 1424 | break; |
| 1425 | } |
| 1426 | } |
| 1427 | fprintf(out, "\n"); |
| 1428 | |
| 1429 | break; |
| 1430 | case 3: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1431 | instr_out(ctx, i, |
Eric Anholt | 0c46f02 | 2011-12-20 14:23:15 -0800 | [diff] [blame] | 1432 | "S3: not documented\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1433 | break; |
| 1434 | case 4: |
| 1435 | { |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 1436 | const char *cullmode = ""; |
| 1437 | const char *vfmt_xyzw = ""; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1438 | switch ((data[i] >> 13) |
| 1439 | & 0x3) { |
| 1440 | case 0: |
| 1441 | cullmode = |
| 1442 | "both"; |
| 1443 | break; |
| 1444 | case 1: |
| 1445 | cullmode = |
| 1446 | "none"; |
| 1447 | break; |
| 1448 | case 2: |
| 1449 | cullmode = "cw"; |
| 1450 | break; |
| 1451 | case 3: |
| 1452 | cullmode = |
| 1453 | "ccw"; |
| 1454 | break; |
| 1455 | } |
| 1456 | switch (data[i] & |
| 1457 | (7 << 6 | 1 << |
| 1458 | 2)) { |
| 1459 | case 1 << 6: |
| 1460 | vfmt_xyzw = |
| 1461 | "XYZ,"; |
| 1462 | break; |
| 1463 | case 2 << 6: |
| 1464 | vfmt_xyzw = |
| 1465 | "XYZW,"; |
| 1466 | break; |
| 1467 | case 3 << 6: |
| 1468 | vfmt_xyzw = |
| 1469 | "XY,"; |
| 1470 | break; |
| 1471 | case 4 << 6: |
| 1472 | vfmt_xyzw = |
| 1473 | "XYW,"; |
| 1474 | break; |
| 1475 | case 1 << 6 | 1 << 2: |
| 1476 | vfmt_xyzw = |
| 1477 | "XYZF,"; |
| 1478 | break; |
| 1479 | case 2 << 6 | 1 << 2: |
| 1480 | vfmt_xyzw = |
| 1481 | "XYZWF,"; |
| 1482 | break; |
| 1483 | case 3 << 6 | 1 << 2: |
| 1484 | vfmt_xyzw = |
| 1485 | "XYF,"; |
| 1486 | break; |
| 1487 | case 4 << 6 | 1 << 2: |
| 1488 | vfmt_xyzw = |
| 1489 | "XYWF,"; |
| 1490 | break; |
| 1491 | } |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1492 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1493 | "S4: point_width=%i, line_width=%.1f," |
| 1494 | "%s%s%s%s%s cullmode=%s, vfmt=%s%s%s%s%s%s " |
Eric Anholt | 0c46f02 | 2011-12-20 14:23:15 -0800 | [diff] [blame] | 1495 | "%s%s%s%s%s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1496 | (data[i] >> |
| 1497 | 23) & 0x1ff, |
| 1498 | ((data[i] >> |
| 1499 | 19) & 0xf) / |
| 1500 | 2.0, |
| 1501 | data[i] & (0xf |
| 1502 | << |
| 1503 | 15) |
| 1504 | ? |
| 1505 | " flatshade=" |
| 1506 | : "", |
| 1507 | data[i] & (1 |
| 1508 | << |
| 1509 | 18) |
| 1510 | ? "Alpha," : |
| 1511 | "", |
| 1512 | data[i] & (1 |
| 1513 | << |
| 1514 | 17) |
| 1515 | ? "Fog," : "", |
| 1516 | data[i] & (1 |
| 1517 | << |
| 1518 | 16) |
| 1519 | ? "Specular," |
| 1520 | : "", |
| 1521 | data[i] & (1 |
| 1522 | << |
| 1523 | 15) |
| 1524 | ? "Color," : |
| 1525 | "", cullmode, |
| 1526 | data[i] & (1 |
| 1527 | << |
| 1528 | 12) |
| 1529 | ? |
| 1530 | "PointWidth," |
| 1531 | : "", |
| 1532 | data[i] & (1 |
| 1533 | << |
| 1534 | 11) |
| 1535 | ? "SpecFog," : |
| 1536 | "", |
| 1537 | data[i] & (1 |
| 1538 | << |
| 1539 | 10) |
| 1540 | ? "Color," : |
| 1541 | "", |
| 1542 | data[i] & (1 |
| 1543 | << |
| 1544 | 9) |
| 1545 | ? "DepthOfs," |
| 1546 | : "", |
| 1547 | vfmt_xyzw, |
| 1548 | data[i] & (1 |
| 1549 | << |
| 1550 | 9) |
| 1551 | ? "FogParam," |
| 1552 | : "", |
| 1553 | data[i] & (1 |
| 1554 | << |
| 1555 | 5) |
| 1556 | ? |
| 1557 | "force default diffuse, " |
| 1558 | : "", |
| 1559 | data[i] & (1 |
| 1560 | << |
| 1561 | 4) |
| 1562 | ? |
| 1563 | "force default specular, " |
| 1564 | : "", |
| 1565 | data[i] & (1 |
| 1566 | << |
| 1567 | 3) |
| 1568 | ? |
| 1569 | "local depth ofs enable, " |
| 1570 | : "", |
| 1571 | data[i] & (1 |
| 1572 | << |
| 1573 | 1) |
| 1574 | ? |
| 1575 | "point sprite enable, " |
| 1576 | : "", |
| 1577 | data[i] & (1 |
| 1578 | << |
| 1579 | 0) |
| 1580 | ? |
| 1581 | "line AA enable, " |
| 1582 | : ""); |
| 1583 | break; |
| 1584 | } |
| 1585 | case 5: |
| 1586 | { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1587 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1588 | "S5:%s%s%s%s%s" |
| 1589 | "%s%s%s%s stencil_ref=0x%x, stencil_test=%s, " |
| 1590 | "stencil_fail=%s, stencil_pass_z_fail=%s, " |
| 1591 | "stencil_pass_z_pass=%s, %s%s%s%s\n", |
| 1592 | data[i] & (0xf |
| 1593 | << |
| 1594 | 28) |
| 1595 | ? |
| 1596 | " write_disable=" |
| 1597 | : "", |
| 1598 | data[i] & (1 |
| 1599 | << |
| 1600 | 31) |
| 1601 | ? "Alpha," : |
| 1602 | "", |
| 1603 | data[i] & (1 |
| 1604 | << |
| 1605 | 30) |
| 1606 | ? "Red," : "", |
| 1607 | data[i] & (1 |
| 1608 | << |
| 1609 | 29) |
| 1610 | ? "Green," : |
| 1611 | "", |
| 1612 | data[i] & (1 |
| 1613 | << |
| 1614 | 28) |
| 1615 | ? "Blue," : |
| 1616 | "", |
| 1617 | data[i] & (1 |
| 1618 | << |
| 1619 | 27) |
| 1620 | ? |
| 1621 | " force default point size," |
| 1622 | : "", |
| 1623 | data[i] & (1 |
| 1624 | << |
| 1625 | 26) |
| 1626 | ? |
| 1627 | " last pixel enable," |
| 1628 | : "", |
| 1629 | data[i] & (1 |
| 1630 | << |
| 1631 | 25) |
| 1632 | ? |
| 1633 | " global depth ofs enable," |
| 1634 | : "", |
| 1635 | data[i] & (1 |
| 1636 | << |
| 1637 | 24) |
| 1638 | ? |
| 1639 | " fog enable," |
| 1640 | : "", |
| 1641 | (data[i] >> |
| 1642 | 16) & 0xff, |
| 1643 | decode_compare_func |
| 1644 | (data[i] >> |
| 1645 | 13), |
| 1646 | decode_stencil_op |
| 1647 | (data[i] >> |
| 1648 | 10), |
| 1649 | decode_stencil_op |
| 1650 | (data[i] >> |
| 1651 | 7), |
| 1652 | decode_stencil_op |
| 1653 | (data[i] >> |
| 1654 | 4), |
| 1655 | data[i] & (1 |
| 1656 | << |
| 1657 | 3) |
| 1658 | ? |
| 1659 | "stencil write enable, " |
| 1660 | : "", |
| 1661 | data[i] & (1 |
| 1662 | << |
| 1663 | 2) |
| 1664 | ? |
| 1665 | "stencil test enable, " |
| 1666 | : "", |
| 1667 | data[i] & (1 |
| 1668 | << |
| 1669 | 1) |
| 1670 | ? |
| 1671 | "color dither enable, " |
| 1672 | : "", |
| 1673 | data[i] & (1 |
| 1674 | << |
| 1675 | 0) |
| 1676 | ? |
| 1677 | "logicop enable, " |
| 1678 | : ""); |
| 1679 | } |
| 1680 | break; |
| 1681 | case 6: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1682 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1683 | "S6: %salpha_test=%s, alpha_ref=0x%x, " |
| 1684 | "depth_test=%s, %ssrc_blnd_fct=%s, dst_blnd_fct=%s, " |
| 1685 | "%s%stristrip_provoking_vertex=%i\n", |
| 1686 | data[i] & (1 << 31) ? |
| 1687 | "alpha test enable, " |
| 1688 | : "", |
| 1689 | decode_compare_func |
| 1690 | (data[i] >> 28), |
| 1691 | data[i] & (0xff << |
| 1692 | 20), |
| 1693 | decode_compare_func |
| 1694 | (data[i] >> 16), |
| 1695 | data[i] & (1 << 15) ? |
| 1696 | "cbuf blend enable, " |
| 1697 | : "", |
| 1698 | decode_blend_fact(data |
| 1699 | [i] |
| 1700 | >> |
| 1701 | 8), |
| 1702 | decode_blend_fact(data |
| 1703 | [i] |
| 1704 | >> |
| 1705 | 4), |
| 1706 | data[i] & (1 << 3) ? |
| 1707 | "depth write enable, " |
| 1708 | : "", |
| 1709 | data[i] & (1 << 2) ? |
| 1710 | "cbuf write enable, " |
| 1711 | : "", |
| 1712 | data[i] & (0x3)); |
| 1713 | break; |
| 1714 | case 7: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1715 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1716 | "S7: depth offset constant: 0x%08x\n", |
| 1717 | data[i]); |
| 1718 | break; |
| 1719 | } |
| 1720 | } else { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1721 | instr_out(ctx, i, |
Chris Wilson | 8cf3475 | 2012-10-07 10:07:23 +0100 | [diff] [blame] | 1722 | "S%d: 0x%08x\n", word, data[i]); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1723 | } |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1724 | i++; |
| 1725 | } |
| 1726 | } |
| 1727 | if (len != i) { |
| 1728 | fprintf(out, |
| 1729 | "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_1\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1730 | } |
| 1731 | return len; |
| 1732 | case 0x03: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1733 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1734 | "3DSTATE_LOAD_STATE_IMMEDIATE_2\n"); |
| 1735 | len = (data[0] & 0x0000000f) + 2; |
| 1736 | i = 1; |
| 1737 | for (word = 6; word <= 14; word++) { |
| 1738 | if (data[0] & (1 << word)) { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1739 | if (word == 6) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1740 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1741 | "TBCF\n"); |
| 1742 | else if (word >= 7 && word <= 10) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1743 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1744 | "TB%dC\n", word - 7); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1745 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1746 | "TB%dA\n", word - 7); |
| 1747 | } else if (word >= 11 && word <= 14) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1748 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1749 | "TM%dS0: offset=0x%08x, %s\n", |
| 1750 | word - 11, |
| 1751 | data[i] & 0xfffffffe, |
| 1752 | data[i] & 1 ? "use fence" : |
| 1753 | ""); |
| 1754 | i++; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1755 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1756 | "TM%dS1: height=%i, width=%i, %s\n", |
| 1757 | word - 11, data[i] >> 21, |
| 1758 | (data[i] >> 10) & 0x3ff, |
| 1759 | data[i] & 2 ? (data[i] & 1 ? |
| 1760 | "y-tiled" : |
| 1761 | "x-tiled") : |
| 1762 | ""); |
| 1763 | i++; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1764 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1765 | "TM%dS2: pitch=%i, \n", |
| 1766 | word - 11, |
| 1767 | ((data[i] >> 21) + 1) * 4); |
| 1768 | i++; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1769 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1770 | "TM%dS3\n", word - 11); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1771 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1772 | "TM%dS4: dflt color\n", |
| 1773 | word - 11); |
| 1774 | } |
| 1775 | } |
| 1776 | } |
| 1777 | if (len != i) { |
| 1778 | fprintf(out, |
| 1779 | "Bad count in 3DSTATE_LOAD_STATE_IMMEDIATE_2\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1780 | } |
| 1781 | return len; |
| 1782 | case 0x00: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1783 | instr_out(ctx, 0, "3DSTATE_MAP_STATE\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1784 | len = (data[0] & 0x0000003f) + 2; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1785 | instr_out(ctx, 1, "mask\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1786 | |
| 1787 | i = 2; |
| 1788 | for (map = 0; map <= 15; map++) { |
| 1789 | if (data[1] & (1 << map)) { |
| 1790 | int width, height, pitch, dword; |
| 1791 | const char *tiling; |
| 1792 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1793 | dword = data[i]; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1794 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1795 | "map %d MS2 %s%s%s\n", map, |
| 1796 | dword & (1 << 31) ? |
| 1797 | "untrusted surface, " : "", |
| 1798 | dword & (1 << 1) ? |
| 1799 | "vertical line stride enable, " : "", |
| 1800 | dword & (1 << 0) ? |
| 1801 | "vertical ofs enable, " : ""); |
| 1802 | |
| 1803 | dword = data[i]; |
| 1804 | width = ((dword >> 10) & ((1 << 11) - 1)) + 1; |
| 1805 | height = ((dword >> 21) & ((1 << 11) - 1)) + 1; |
| 1806 | |
| 1807 | tiling = "none"; |
| 1808 | if (dword & (1 << 2)) |
| 1809 | tiling = "fenced"; |
| 1810 | else if (dword & (1 << 1)) |
| 1811 | tiling = dword & (1 << 0) ? "Y" : "X"; |
| 1812 | type = " BAD"; |
| 1813 | format = "BAD"; |
| 1814 | switch ((dword >> 7) & 0x7) { |
| 1815 | case 1: |
| 1816 | type = "8b"; |
| 1817 | switch ((dword >> 3) & 0xf) { |
| 1818 | case 0: |
| 1819 | format = "I"; |
| 1820 | break; |
| 1821 | case 1: |
| 1822 | format = "L"; |
| 1823 | break; |
| 1824 | case 4: |
| 1825 | format = "A"; |
| 1826 | break; |
| 1827 | case 5: |
| 1828 | format = " mono"; |
| 1829 | break; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1830 | } |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1831 | break; |
| 1832 | case 2: |
| 1833 | type = "16b"; |
| 1834 | switch ((dword >> 3) & 0xf) { |
| 1835 | case 0: |
| 1836 | format = " rgb565"; |
| 1837 | break; |
| 1838 | case 1: |
| 1839 | format = " argb1555"; |
| 1840 | break; |
| 1841 | case 2: |
| 1842 | format = " argb4444"; |
| 1843 | break; |
| 1844 | case 5: |
| 1845 | format = " ay88"; |
| 1846 | break; |
| 1847 | case 6: |
| 1848 | format = " bump655"; |
| 1849 | break; |
| 1850 | case 7: |
| 1851 | format = "I"; |
| 1852 | break; |
| 1853 | case 8: |
| 1854 | format = "L"; |
| 1855 | break; |
| 1856 | case 9: |
| 1857 | format = "A"; |
| 1858 | break; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1859 | } |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1860 | break; |
| 1861 | case 3: |
| 1862 | type = "32b"; |
| 1863 | switch ((dword >> 3) & 0xf) { |
| 1864 | case 0: |
| 1865 | format = " argb8888"; |
| 1866 | break; |
| 1867 | case 1: |
| 1868 | format = " abgr8888"; |
| 1869 | break; |
| 1870 | case 2: |
| 1871 | format = " xrgb8888"; |
| 1872 | break; |
| 1873 | case 3: |
| 1874 | format = " xbgr8888"; |
| 1875 | break; |
| 1876 | case 4: |
| 1877 | format = " qwvu8888"; |
| 1878 | break; |
| 1879 | case 5: |
| 1880 | format = " axvu8888"; |
| 1881 | break; |
| 1882 | case 6: |
| 1883 | format = " lxvu8888"; |
| 1884 | break; |
| 1885 | case 7: |
| 1886 | format = " xlvu8888"; |
| 1887 | break; |
| 1888 | case 8: |
| 1889 | format = " argb2101010"; |
| 1890 | break; |
| 1891 | case 9: |
| 1892 | format = " abgr2101010"; |
| 1893 | break; |
| 1894 | case 10: |
| 1895 | format = " awvu2101010"; |
| 1896 | break; |
| 1897 | case 11: |
| 1898 | format = " gr1616"; |
| 1899 | break; |
| 1900 | case 12: |
| 1901 | format = " vu1616"; |
| 1902 | break; |
| 1903 | case 13: |
| 1904 | format = " xI824"; |
| 1905 | break; |
| 1906 | case 14: |
| 1907 | format = " xA824"; |
| 1908 | break; |
| 1909 | case 15: |
| 1910 | format = " xL824"; |
| 1911 | break; |
| 1912 | } |
| 1913 | break; |
| 1914 | case 5: |
| 1915 | type = "422"; |
| 1916 | switch ((dword >> 3) & 0xf) { |
| 1917 | case 0: |
| 1918 | format = " yuv_swapy"; |
| 1919 | break; |
| 1920 | case 1: |
| 1921 | format = " yuv"; |
| 1922 | break; |
| 1923 | case 2: |
| 1924 | format = " yuv_swapuv"; |
| 1925 | break; |
| 1926 | case 3: |
| 1927 | format = " yuv_swapuvy"; |
| 1928 | break; |
| 1929 | } |
| 1930 | break; |
| 1931 | case 6: |
| 1932 | type = "compressed"; |
| 1933 | switch ((dword >> 3) & 0x7) { |
| 1934 | case 0: |
| 1935 | format = " dxt1"; |
| 1936 | break; |
| 1937 | case 1: |
| 1938 | format = " dxt2_3"; |
| 1939 | break; |
| 1940 | case 2: |
| 1941 | format = " dxt4_5"; |
| 1942 | break; |
| 1943 | case 3: |
| 1944 | format = " fxt1"; |
| 1945 | break; |
| 1946 | case 4: |
| 1947 | format = " dxt1_rb"; |
| 1948 | break; |
| 1949 | } |
| 1950 | break; |
| 1951 | case 7: |
| 1952 | type = "4b indexed"; |
| 1953 | switch ((dword >> 3) & 0xf) { |
| 1954 | case 7: |
| 1955 | format = " argb8888"; |
| 1956 | break; |
| 1957 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 1958 | break; |
| 1959 | } |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1960 | dword = data[i]; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1961 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1962 | "map %d MS3 [width=%d, height=%d, format=%s%s, tiling=%s%s]\n", |
| 1963 | map, width, height, type, format, |
| 1964 | tiling, |
| 1965 | dword & (1 << 9) ? " palette select" : |
| 1966 | ""); |
| 1967 | |
| 1968 | dword = data[i]; |
| 1969 | pitch = |
| 1970 | 4 * (((dword >> 21) & ((1 << 11) - 1)) + 1); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1971 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1972 | "map %d MS4 [pitch=%d, max_lod=%i, vol_depth=%i, cube_face_ena=%x, %s]\n", |
| 1973 | map, pitch, (dword >> 9) & 0x3f, |
| 1974 | dword & 0xff, (dword >> 15) & 0x3f, |
| 1975 | dword & (1 << 8) ? "miplayout legacy" |
| 1976 | : "miplayout right"); |
| 1977 | } |
| 1978 | } |
| 1979 | if (len != i) { |
| 1980 | fprintf(out, "Bad count in 3DSTATE_MAP_STATE\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1981 | return len; |
| 1982 | } |
| 1983 | return len; |
| 1984 | case 0x06: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1985 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1986 | "3DSTATE_PIXEL_SHADER_CONSTANTS\n"); |
| 1987 | len = (data[0] & 0x000000ff) + 2; |
| 1988 | |
| 1989 | i = 2; |
| 1990 | for (c = 0; c <= 31; c++) { |
| 1991 | if (data[1] & (1 << c)) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1992 | instr_out(ctx, i, "C%d.X = %f\n", c, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1993 | int_as_float(data[i])); |
| 1994 | i++; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1995 | instr_out(ctx, i, "C%d.Y = %f\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1996 | c, int_as_float(data[i])); |
| 1997 | i++; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 1998 | instr_out(ctx, i, "C%d.Z = %f\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 1999 | c, int_as_float(data[i])); |
| 2000 | i++; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2001 | instr_out(ctx, i, "C%d.W = %f\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2002 | c, int_as_float(data[i])); |
| 2003 | i++; |
| 2004 | } |
| 2005 | } |
| 2006 | if (len != i) { |
| 2007 | fprintf(out, |
| 2008 | "Bad count in 3DSTATE_PIXEL_SHADER_CONSTANTS\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2009 | } |
| 2010 | return len; |
| 2011 | case 0x05: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2012 | instr_out(ctx, 0, "3DSTATE_PIXEL_SHADER_PROGRAM\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2013 | len = (data[0] & 0x000000ff) + 2; |
| 2014 | if ((len - 1) % 3 != 0 || len > 370) { |
| 2015 | fprintf(out, |
| 2016 | "Bad count in 3DSTATE_PIXEL_SHADER_PROGRAM\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2017 | } |
| 2018 | i = 1; |
| 2019 | for (instr = 0; instr < (len - 1) / 3; instr++) { |
| 2020 | char instr_prefix[10]; |
| 2021 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2022 | sprintf(instr_prefix, "PS%03d", instr); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2023 | i915_decode_instruction(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2024 | instr_prefix); |
| 2025 | i += 3; |
| 2026 | } |
| 2027 | return len; |
| 2028 | case 0x01: |
| 2029 | if (IS_GEN2(devid)) |
| 2030 | break; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2031 | instr_out(ctx, 0, "3DSTATE_SAMPLER_STATE\n"); |
| 2032 | instr_out(ctx, 1, "mask\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2033 | len = (data[0] & 0x0000003f) + 2; |
| 2034 | i = 2; |
| 2035 | for (sampler = 0; sampler <= 15; sampler++) { |
| 2036 | if (data[1] & (1 << sampler)) { |
| 2037 | uint32_t dword; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 2038 | const char *mip_filter = ""; |
Eric Anholt | 028715e | 2012-01-04 12:31:40 -0800 | [diff] [blame] | 2039 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2040 | dword = data[i]; |
| 2041 | switch ((dword >> 20) & 0x3) { |
| 2042 | case 0: |
| 2043 | mip_filter = "none"; |
| 2044 | break; |
| 2045 | case 1: |
| 2046 | mip_filter = "nearest"; |
| 2047 | break; |
| 2048 | case 3: |
| 2049 | mip_filter = "linear"; |
| 2050 | break; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2051 | } |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2052 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2053 | "sampler %d SS2:%s%s%s " |
| 2054 | "base_mip_level=%i, mip_filter=%s, mag_filter=%s, min_filter=%s " |
| 2055 | "lod_bias=%.2f,%s max_aniso=%i, shadow_func=%s\n", |
| 2056 | sampler, |
| 2057 | dword & (1 << 31) ? " reverse gamma," |
| 2058 | : "", |
| 2059 | dword & (1 << 30) ? " packed2planar," |
| 2060 | : "", |
| 2061 | dword & (1 << 29) ? |
| 2062 | " colorspace conversion," : "", |
| 2063 | (dword >> 22) & 0x1f, mip_filter, |
| 2064 | decode_sample_filter(dword >> 17), |
| 2065 | decode_sample_filter(dword >> 14), |
| 2066 | ((dword >> 5) & 0x1ff) / (0x10 * 1.0), |
| 2067 | dword & (1 << 4) ? " shadow," : "", |
| 2068 | dword & (1 << 3) ? 4 : 2, |
| 2069 | decode_compare_func(dword)); |
| 2070 | dword = data[i]; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2071 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2072 | "sampler %d SS3: min_lod=%.2f,%s " |
| 2073 | "tcmode_x=%s, tcmode_y=%s, tcmode_z=%s,%s texmap_idx=%i,%s\n", |
| 2074 | sampler, |
| 2075 | ((dword >> 24) & 0xff) / (0x10 * 1.0), |
| 2076 | dword & (1 << 17) ? |
| 2077 | " kill pixel enable," : "", |
| 2078 | decode_tex_coord_mode(dword >> 12), |
| 2079 | decode_tex_coord_mode(dword >> 9), |
| 2080 | decode_tex_coord_mode(dword >> 6), |
| 2081 | dword & (1 << 5) ? |
| 2082 | " normalized coords," : "", |
| 2083 | (dword >> 1) & 0xf, |
| 2084 | dword & (1 << 0) ? " deinterlacer," : |
| 2085 | ""); |
| 2086 | dword = data[i]; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2087 | instr_out(ctx, i++, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2088 | "sampler %d SS4: border color\n", |
Eric Anholt | 0c46f02 | 2011-12-20 14:23:15 -0800 | [diff] [blame] | 2089 | sampler); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2090 | } |
| 2091 | } |
| 2092 | if (len != i) { |
| 2093 | fprintf(out, "Bad count in 3DSTATE_SAMPLER_STATE\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2094 | } |
| 2095 | return len; |
| 2096 | case 0x85: |
| 2097 | len = (data[0] & 0x0000000f) + 2; |
| 2098 | |
| 2099 | if (len != 2) |
| 2100 | fprintf(out, |
| 2101 | "Bad count in 3DSTATE_DEST_BUFFER_VARIABLES\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2102 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2103 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2104 | "3DSTATE_DEST_BUFFER_VARIABLES\n"); |
| 2105 | |
| 2106 | switch ((data[1] >> 8) & 0xf) { |
| 2107 | case 0x0: |
| 2108 | format = "g8"; |
| 2109 | break; |
| 2110 | case 0x1: |
| 2111 | format = "x1r5g5b5"; |
| 2112 | break; |
| 2113 | case 0x2: |
| 2114 | format = "r5g6b5"; |
| 2115 | break; |
| 2116 | case 0x3: |
| 2117 | format = "a8r8g8b8"; |
| 2118 | break; |
| 2119 | case 0x4: |
| 2120 | format = "ycrcb_swapy"; |
| 2121 | break; |
| 2122 | case 0x5: |
| 2123 | format = "ycrcb_normal"; |
| 2124 | break; |
| 2125 | case 0x6: |
| 2126 | format = "ycrcb_swapuv"; |
| 2127 | break; |
| 2128 | case 0x7: |
| 2129 | format = "ycrcb_swapuvy"; |
| 2130 | break; |
| 2131 | case 0x8: |
| 2132 | format = "a4r4g4b4"; |
| 2133 | break; |
| 2134 | case 0x9: |
| 2135 | format = "a1r5g5b5"; |
| 2136 | break; |
| 2137 | case 0xa: |
| 2138 | format = "a2r10g10b10"; |
| 2139 | break; |
| 2140 | default: |
| 2141 | format = "BAD"; |
| 2142 | break; |
| 2143 | } |
| 2144 | switch ((data[1] >> 2) & 0x3) { |
| 2145 | case 0x0: |
| 2146 | zformat = "u16"; |
| 2147 | break; |
| 2148 | case 0x1: |
| 2149 | zformat = "f16"; |
| 2150 | break; |
| 2151 | case 0x2: |
| 2152 | zformat = "u24x8"; |
| 2153 | break; |
| 2154 | default: |
| 2155 | zformat = "BAD"; |
| 2156 | break; |
| 2157 | } |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2158 | instr_out(ctx, 1, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2159 | "%s format, %s depth format, early Z %sabled\n", |
| 2160 | format, zformat, |
| 2161 | (data[1] & (1 << 31)) ? "en" : "dis"); |
| 2162 | return len; |
| 2163 | |
| 2164 | case 0x8e: |
| 2165 | { |
| 2166 | const char *name, *tiling; |
| 2167 | |
| 2168 | len = (data[0] & 0x0000000f) + 2; |
| 2169 | if (len != 3) |
| 2170 | fprintf(out, |
| 2171 | "Bad count in 3DSTATE_BUFFER_INFO\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2172 | |
| 2173 | switch ((data[1] >> 24) & 0x7) { |
| 2174 | case 0x3: |
| 2175 | name = "color"; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2176 | break; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2177 | case 0x7: |
| 2178 | name = "depth"; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2179 | break; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2180 | default: |
| 2181 | name = "unknown"; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2182 | break; |
| 2183 | } |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2184 | |
| 2185 | tiling = "none"; |
| 2186 | if (data[1] & (1 << 23)) |
| 2187 | tiling = "fenced"; |
| 2188 | else if (data[1] & (1 << 22)) |
| 2189 | tiling = data[1] & (1 << 21) ? "Y" : "X"; |
| 2190 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2191 | instr_out(ctx, 0, "3DSTATE_BUFFER_INFO\n"); |
| 2192 | instr_out(ctx, 1, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2193 | "%s, tiling = %s, pitch=%d\n", name, tiling, |
| 2194 | data[1] & 0xffff); |
| 2195 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2196 | instr_out(ctx, 2, "address\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2197 | return len; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2198 | } |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2199 | case 0x81: |
| 2200 | len = (data[0] & 0x0000000f) + 2; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2201 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2202 | if (len != 3) |
| 2203 | fprintf(out, |
| 2204 | "Bad count in 3DSTATE_SCISSOR_RECTANGLE\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2205 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2206 | instr_out(ctx, 0, "3DSTATE_SCISSOR_RECTANGLE\n"); |
| 2207 | instr_out(ctx, 1, "(%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2208 | data[1] & 0xffff, data[1] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2209 | instr_out(ctx, 2, "(%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2210 | data[2] & 0xffff, data[2] >> 16); |
| 2211 | |
| 2212 | return len; |
| 2213 | case 0x80: |
| 2214 | len = (data[0] & 0x0000000f) + 2; |
| 2215 | |
| 2216 | if (len != 5) |
| 2217 | fprintf(out, |
| 2218 | "Bad count in 3DSTATE_DRAWING_RECTANGLE\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2219 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2220 | instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n"); |
| 2221 | instr_out(ctx, 1, "%s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2222 | data[1] & (1 << 30) ? "depth ofs disabled " : ""); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2223 | instr_out(ctx, 2, "(%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2224 | data[2] & 0xffff, data[2] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2225 | instr_out(ctx, 3, "(%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2226 | data[3] & 0xffff, data[3] >> 16); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2227 | instr_out(ctx, 4, "(%d,%d)\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2228 | data[4] & 0xffff, data[4] >> 16); |
| 2229 | |
| 2230 | return len; |
| 2231 | case 0x9c: |
| 2232 | len = (data[0] & 0x0000000f) + 2; |
| 2233 | |
| 2234 | if (len != 7) |
| 2235 | fprintf(out, "Bad count in 3DSTATE_CLEAR_PARAMETERS\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2236 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2237 | instr_out(ctx, 0, "3DSTATE_CLEAR_PARAMETERS\n"); |
| 2238 | instr_out(ctx, 1, "prim_type=%s, clear=%s%s%s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2239 | data[1] & (1 << 16) ? "CLEAR_RECT" : "ZONE_INIT", |
| 2240 | data[1] & (1 << 2) ? "color," : "", |
| 2241 | data[1] & (1 << 1) ? "depth," : "", |
| 2242 | data[1] & (1 << 0) ? "stencil," : ""); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2243 | instr_out(ctx, 2, "clear color\n"); |
| 2244 | instr_out(ctx, 3, "clear depth/stencil\n"); |
| 2245 | instr_out(ctx, 4, "color value (rgba8888)\n"); |
| 2246 | instr_out(ctx, 5, "depth value %f\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2247 | int_as_float(data[5])); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2248 | instr_out(ctx, 6, "clear stencil\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2249 | return len; |
| 2250 | } |
| 2251 | |
| 2252 | for (idx = 0; idx < ARRAY_SIZE(opcodes_3d_1d); idx++) { |
| 2253 | opcode_3d_1d = &opcodes_3d_1d[idx]; |
| 2254 | if (opcode_3d_1d->i830_only && !IS_GEN2(devid)) |
| 2255 | continue; |
| 2256 | |
| 2257 | if (((data[0] & 0x00ff0000) >> 16) == opcode_3d_1d->opcode) { |
| 2258 | len = 1; |
| 2259 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2260 | instr_out(ctx, 0, "%s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2261 | opcode_3d_1d->name); |
| 2262 | if (opcode_3d_1d->max_len > 1) { |
| 2263 | len = (data[0] & 0x0000ffff) + 2; |
| 2264 | if (len < opcode_3d_1d->min_len || |
| 2265 | len > opcode_3d_1d->max_len) { |
| 2266 | fprintf(out, "Bad count in %s\n", |
| 2267 | opcode_3d_1d->name); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2268 | } |
| 2269 | } |
| 2270 | |
| 2271 | for (i = 1; i < len; i++) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2272 | instr_out(ctx, i, "dword %d\n", i); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2273 | } |
| 2274 | |
| 2275 | return len; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2276 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2277 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2278 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2279 | instr_out(ctx, 0, "3D UNKNOWN: 3d_1d opcode = 0x%x\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2280 | opcode); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2281 | return 1; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2282 | } |
| 2283 | |
| 2284 | static int |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 2285 | decode_3d_primitive(struct drm_intel_decode *ctx) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2286 | { |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 2287 | uint32_t *data = ctx->data; |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 2288 | uint32_t count = ctx->count; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2289 | char immediate = (data[0] & (1 << 23)) == 0; |
| 2290 | unsigned int len, i, j, ret; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 2291 | const char *primtype; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2292 | int original_s2 = saved_s2; |
| 2293 | int original_s4 = saved_s4; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2294 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2295 | switch ((data[0] >> 18) & 0xf) { |
| 2296 | case 0x0: |
| 2297 | primtype = "TRILIST"; |
| 2298 | break; |
| 2299 | case 0x1: |
| 2300 | primtype = "TRISTRIP"; |
| 2301 | break; |
| 2302 | case 0x2: |
| 2303 | primtype = "TRISTRIP_REVERSE"; |
| 2304 | break; |
| 2305 | case 0x3: |
| 2306 | primtype = "TRIFAN"; |
| 2307 | break; |
| 2308 | case 0x4: |
| 2309 | primtype = "POLYGON"; |
| 2310 | break; |
| 2311 | case 0x5: |
| 2312 | primtype = "LINELIST"; |
| 2313 | break; |
| 2314 | case 0x6: |
| 2315 | primtype = "LINESTRIP"; |
| 2316 | break; |
| 2317 | case 0x7: |
| 2318 | primtype = "RECTLIST"; |
| 2319 | break; |
| 2320 | case 0x8: |
| 2321 | primtype = "POINTLIST"; |
| 2322 | break; |
| 2323 | case 0x9: |
| 2324 | primtype = "DIB"; |
| 2325 | break; |
| 2326 | case 0xa: |
| 2327 | primtype = "CLEAR_RECT"; |
| 2328 | saved_s4 = 3 << 6; |
| 2329 | saved_s2 = ~0; |
| 2330 | break; |
| 2331 | default: |
| 2332 | primtype = "unknown"; |
| 2333 | break; |
| 2334 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2335 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2336 | /* XXX: 3DPRIM_DIB not supported */ |
| 2337 | if (immediate) { |
| 2338 | len = (data[0] & 0x0003ffff) + 2; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2339 | instr_out(ctx, 0, "3DPRIMITIVE inline %s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2340 | primtype); |
| 2341 | if (count < len) |
| 2342 | BUFFER_FAIL(count, len, "3DPRIMITIVE inline"); |
| 2343 | if (!saved_s2_set || !saved_s4_set) { |
| 2344 | fprintf(out, "unknown vertex format\n"); |
| 2345 | for (i = 1; i < len; i++) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2346 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2347 | " vertex data (%f float)\n", |
| 2348 | int_as_float(data[i])); |
| 2349 | } |
| 2350 | } else { |
| 2351 | unsigned int vertex = 0; |
| 2352 | for (i = 1; i < len;) { |
| 2353 | unsigned int tc; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2354 | |
| 2355 | #define VERTEX_OUT(fmt, ...) do { \ |
| 2356 | if (i < len) \ |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2357 | instr_out(ctx, i, " V%d."fmt"\n", vertex, __VA_ARGS__); \ |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2358 | else \ |
| 2359 | fprintf(out, " missing data in V%d\n", vertex); \ |
| 2360 | i++; \ |
| 2361 | } while (0) |
| 2362 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2363 | VERTEX_OUT("X = %f", int_as_float(data[i])); |
| 2364 | VERTEX_OUT("Y = %f", int_as_float(data[i])); |
| 2365 | switch (saved_s4 >> 6 & 0x7) { |
| 2366 | case 0x1: |
| 2367 | VERTEX_OUT("Z = %f", |
| 2368 | int_as_float(data[i])); |
| 2369 | break; |
| 2370 | case 0x2: |
| 2371 | VERTEX_OUT("Z = %f", |
| 2372 | int_as_float(data[i])); |
| 2373 | VERTEX_OUT("W = %f", |
| 2374 | int_as_float(data[i])); |
| 2375 | break; |
| 2376 | case 0x3: |
| 2377 | break; |
| 2378 | case 0x4: |
| 2379 | VERTEX_OUT("W = %f", |
| 2380 | int_as_float(data[i])); |
| 2381 | break; |
| 2382 | default: |
| 2383 | fprintf(out, "bad S4 position mask\n"); |
| 2384 | } |
| 2385 | |
| 2386 | if (saved_s4 & (1 << 10)) { |
| 2387 | VERTEX_OUT |
| 2388 | ("color = (A=0x%02x, R=0x%02x, G=0x%02x, " |
| 2389 | "B=0x%02x)", data[i] >> 24, |
| 2390 | (data[i] >> 16) & 0xff, |
| 2391 | (data[i] >> 8) & 0xff, |
| 2392 | data[i] & 0xff); |
| 2393 | } |
| 2394 | if (saved_s4 & (1 << 11)) { |
| 2395 | VERTEX_OUT |
| 2396 | ("spec = (A=0x%02x, R=0x%02x, G=0x%02x, " |
| 2397 | "B=0x%02x)", data[i] >> 24, |
| 2398 | (data[i] >> 16) & 0xff, |
| 2399 | (data[i] >> 8) & 0xff, |
| 2400 | data[i] & 0xff); |
| 2401 | } |
| 2402 | if (saved_s4 & (1 << 12)) |
| 2403 | VERTEX_OUT("width = 0x%08x)", data[i]); |
| 2404 | |
| 2405 | for (tc = 0; tc <= 7; tc++) { |
| 2406 | switch ((saved_s2 >> (tc * 4)) & 0xf) { |
| 2407 | case 0x0: |
| 2408 | VERTEX_OUT("T%d.X = %f", tc, |
| 2409 | int_as_float(data |
| 2410 | [i])); |
| 2411 | VERTEX_OUT("T%d.Y = %f", tc, |
| 2412 | int_as_float(data |
| 2413 | [i])); |
| 2414 | break; |
| 2415 | case 0x1: |
| 2416 | VERTEX_OUT("T%d.X = %f", tc, |
| 2417 | int_as_float(data |
| 2418 | [i])); |
| 2419 | VERTEX_OUT("T%d.Y = %f", tc, |
| 2420 | int_as_float(data |
| 2421 | [i])); |
| 2422 | VERTEX_OUT("T%d.Z = %f", tc, |
| 2423 | int_as_float(data |
| 2424 | [i])); |
| 2425 | break; |
| 2426 | case 0x2: |
| 2427 | VERTEX_OUT("T%d.X = %f", tc, |
| 2428 | int_as_float(data |
| 2429 | [i])); |
| 2430 | VERTEX_OUT("T%d.Y = %f", tc, |
| 2431 | int_as_float(data |
| 2432 | [i])); |
| 2433 | VERTEX_OUT("T%d.Z = %f", tc, |
| 2434 | int_as_float(data |
| 2435 | [i])); |
| 2436 | VERTEX_OUT("T%d.W = %f", tc, |
| 2437 | int_as_float(data |
| 2438 | [i])); |
| 2439 | break; |
| 2440 | case 0x3: |
| 2441 | VERTEX_OUT("T%d.X = %f", tc, |
| 2442 | int_as_float(data |
| 2443 | [i])); |
| 2444 | break; |
| 2445 | case 0x4: |
| 2446 | VERTEX_OUT |
| 2447 | ("T%d.XY = 0x%08x half-float", |
| 2448 | tc, data[i]); |
| 2449 | break; |
| 2450 | case 0x5: |
| 2451 | VERTEX_OUT |
| 2452 | ("T%d.XY = 0x%08x half-float", |
| 2453 | tc, data[i]); |
| 2454 | VERTEX_OUT |
| 2455 | ("T%d.ZW = 0x%08x half-float", |
| 2456 | tc, data[i]); |
| 2457 | break; |
| 2458 | case 0xf: |
| 2459 | break; |
| 2460 | default: |
| 2461 | fprintf(out, |
| 2462 | "bad S2.T%d format\n", |
| 2463 | tc); |
| 2464 | } |
| 2465 | } |
| 2466 | vertex++; |
| 2467 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2468 | } |
| 2469 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2470 | ret = len; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2471 | } else { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2472 | /* indirect vertices */ |
| 2473 | len = data[0] & 0x0000ffff; /* index count */ |
| 2474 | if (data[0] & (1 << 17)) { |
| 2475 | /* random vertex access */ |
| 2476 | if (count < (len + 1) / 2 + 1) { |
| 2477 | BUFFER_FAIL(count, (len + 1) / 2 + 1, |
| 2478 | "3DPRIMITIVE random indirect"); |
| 2479 | } |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2480 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2481 | "3DPRIMITIVE random indirect %s (%d)\n", |
| 2482 | primtype, len); |
| 2483 | if (len == 0) { |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 2484 | /* vertex indices continue until 0xffff is |
| 2485 | * found |
| 2486 | */ |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2487 | for (i = 1; i < count; i++) { |
| 2488 | if ((data[i] & 0xffff) == 0xffff) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2489 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2490 | " indices: (terminator)\n"); |
| 2491 | ret = i; |
| 2492 | goto out; |
| 2493 | } else if ((data[i] >> 16) == 0xffff) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2494 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2495 | " indices: 0x%04x, (terminator)\n", |
| 2496 | data[i] & 0xffff); |
| 2497 | ret = i; |
| 2498 | goto out; |
| 2499 | } else { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2500 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2501 | " indices: 0x%04x, 0x%04x\n", |
| 2502 | data[i] & 0xffff, |
| 2503 | data[i] >> 16); |
| 2504 | } |
| 2505 | } |
| 2506 | fprintf(out, |
| 2507 | "3DPRIMITIVE: no terminator found in index buffer\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2508 | ret = count; |
| 2509 | goto out; |
| 2510 | } else { |
| 2511 | /* fixed size vertex index buffer */ |
| 2512 | for (j = 1, i = 0; i < len; i += 2, j++) { |
| 2513 | if (i * 2 == len - 1) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2514 | instr_out(ctx, j, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2515 | " indices: 0x%04x\n", |
| 2516 | data[j] & 0xffff); |
| 2517 | } else { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2518 | instr_out(ctx, j, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2519 | " indices: 0x%04x, 0x%04x\n", |
| 2520 | data[j] & 0xffff, |
| 2521 | data[j] >> 16); |
| 2522 | } |
| 2523 | } |
| 2524 | } |
| 2525 | ret = (len + 1) / 2 + 1; |
| 2526 | goto out; |
| 2527 | } else { |
| 2528 | /* sequential vertex access */ |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2529 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2530 | "3DPRIMITIVE sequential indirect %s, %d starting from " |
| 2531 | "%d\n", primtype, len, data[1] & 0xffff); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2532 | instr_out(ctx, 1, " start\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2533 | ret = 2; |
| 2534 | goto out; |
| 2535 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2536 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2537 | |
| 2538 | out: |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2539 | saved_s2 = original_s2; |
| 2540 | saved_s4 = original_s4; |
| 2541 | return ret; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2542 | } |
| 2543 | |
| 2544 | static int |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 2545 | decode_3d(struct drm_intel_decode *ctx) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2546 | { |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2547 | uint32_t opcode; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2548 | unsigned int idx; |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 2549 | uint32_t *data = ctx->data; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2550 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2551 | struct { |
| 2552 | uint32_t opcode; |
Eric Anholt | 07768ba | 2011-12-20 13:46:23 -0800 | [diff] [blame] | 2553 | unsigned int min_len; |
| 2554 | unsigned int max_len; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 2555 | const char *name; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2556 | } opcodes_3d[] = { |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 2557 | { 0x06, 1, 1, "3DSTATE_ANTI_ALIASING" }, |
| 2558 | { 0x08, 1, 1, "3DSTATE_BACKFACE_STENCIL_OPS" }, |
| 2559 | { 0x09, 1, 1, "3DSTATE_BACKFACE_STENCIL_MASKS" }, |
| 2560 | { 0x16, 1, 1, "3DSTATE_COORD_SET_BINDINGS" }, |
| 2561 | { 0x15, 1, 1, "3DSTATE_FOG_COLOR" }, |
| 2562 | { 0x0b, 1, 1, "3DSTATE_INDEPENDENT_ALPHA_BLEND" }, |
| 2563 | { 0x0d, 1, 1, "3DSTATE_MODES_4" }, |
| 2564 | { 0x0c, 1, 1, "3DSTATE_MODES_5" }, |
| 2565 | { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES"}, |
| 2566 | }, *opcode_3d; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2567 | |
| 2568 | opcode = (data[0] & 0x1f000000) >> 24; |
| 2569 | |
| 2570 | switch (opcode) { |
| 2571 | case 0x1f: |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 2572 | return decode_3d_primitive(ctx); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2573 | case 0x1d: |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 2574 | return decode_3d_1d(ctx); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2575 | case 0x1c: |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 2576 | return decode_3d_1c(ctx); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2577 | } |
| 2578 | |
| 2579 | for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) { |
| 2580 | opcode_3d = &opcodes_3d[idx]; |
| 2581 | if (opcode == opcode_3d->opcode) { |
| 2582 | unsigned int len = 1, i; |
| 2583 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2584 | instr_out(ctx, 0, "%s\n", opcode_3d->name); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2585 | if (opcode_3d->max_len > 1) { |
| 2586 | len = (data[0] & 0xff) + 2; |
| 2587 | if (len < opcode_3d->min_len || |
| 2588 | len > opcode_3d->max_len) { |
| 2589 | fprintf(out, "Bad count in %s\n", |
| 2590 | opcode_3d->name); |
| 2591 | } |
| 2592 | } |
| 2593 | |
| 2594 | for (i = 1; i < len; i++) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2595 | instr_out(ctx, i, "dword %d\n", i); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2596 | } |
| 2597 | return len; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2598 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2599 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2600 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2601 | instr_out(ctx, 0, "3D UNKNOWN: 3d opcode = 0x%x\n", opcode); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2602 | return 1; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2603 | } |
| 2604 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2605 | static const char *get_965_surfacetype(unsigned int surfacetype) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2606 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2607 | switch (surfacetype) { |
| 2608 | case 0: |
| 2609 | return "1D"; |
| 2610 | case 1: |
| 2611 | return "2D"; |
| 2612 | case 2: |
| 2613 | return "3D"; |
| 2614 | case 3: |
| 2615 | return "CUBE"; |
| 2616 | case 4: |
| 2617 | return "BUFFER"; |
| 2618 | case 7: |
| 2619 | return "NULL"; |
| 2620 | default: |
| 2621 | return "unknown"; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2622 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2623 | } |
| 2624 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2625 | static const char *get_965_depthformat(unsigned int depthformat) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2626 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2627 | switch (depthformat) { |
| 2628 | case 0: |
| 2629 | return "s8_z24float"; |
| 2630 | case 1: |
| 2631 | return "z32float"; |
| 2632 | case 2: |
| 2633 | return "z24s8"; |
| 2634 | case 5: |
| 2635 | return "z16"; |
| 2636 | default: |
| 2637 | return "unknown"; |
| 2638 | } |
| 2639 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2640 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2641 | static const char *get_965_element_component(uint32_t data, int component) |
| 2642 | { |
| 2643 | uint32_t component_control = (data >> (16 + (3 - component) * 4)) & 0x7; |
| 2644 | |
| 2645 | switch (component_control) { |
| 2646 | case 0: |
| 2647 | return "nostore"; |
| 2648 | case 1: |
| 2649 | switch (component) { |
| 2650 | case 0: |
| 2651 | return "X"; |
| 2652 | case 1: |
| 2653 | return "Y"; |
| 2654 | case 2: |
| 2655 | return "Z"; |
| 2656 | case 3: |
| 2657 | return "W"; |
| 2658 | default: |
| 2659 | return "fail"; |
| 2660 | } |
| 2661 | case 2: |
| 2662 | return "0.0"; |
| 2663 | case 3: |
| 2664 | return "1.0"; |
| 2665 | case 4: |
| 2666 | return "0x1"; |
| 2667 | case 5: |
| 2668 | return "VID"; |
| 2669 | default: |
| 2670 | return "fail"; |
| 2671 | } |
| 2672 | } |
| 2673 | |
Eric Anholt | 9d18ad2 | 2012-03-02 10:27:55 -0800 | [diff] [blame] | 2674 | static const char *get_965_prim_type(uint32_t primtype) |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2675 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2676 | switch (primtype) { |
| 2677 | case 0x01: |
| 2678 | return "point list"; |
| 2679 | case 0x02: |
| 2680 | return "line list"; |
| 2681 | case 0x03: |
| 2682 | return "line strip"; |
| 2683 | case 0x04: |
| 2684 | return "tri list"; |
| 2685 | case 0x05: |
| 2686 | return "tri strip"; |
| 2687 | case 0x06: |
| 2688 | return "tri fan"; |
| 2689 | case 0x07: |
| 2690 | return "quad list"; |
| 2691 | case 0x08: |
| 2692 | return "quad strip"; |
| 2693 | case 0x09: |
| 2694 | return "line list adj"; |
| 2695 | case 0x0a: |
| 2696 | return "line strip adj"; |
| 2697 | case 0x0b: |
| 2698 | return "tri list adj"; |
| 2699 | case 0x0c: |
| 2700 | return "tri strip adj"; |
| 2701 | case 0x0d: |
| 2702 | return "tri strip reverse"; |
| 2703 | case 0x0e: |
| 2704 | return "polygon"; |
| 2705 | case 0x0f: |
| 2706 | return "rect list"; |
| 2707 | case 0x10: |
| 2708 | return "line loop"; |
| 2709 | case 0x11: |
| 2710 | return "point list bf"; |
| 2711 | case 0x12: |
| 2712 | return "line strip cont"; |
| 2713 | case 0x13: |
| 2714 | return "line strip bf"; |
| 2715 | case 0x14: |
| 2716 | return "line strip cont bf"; |
| 2717 | case 0x15: |
| 2718 | return "tri fan no stipple"; |
| 2719 | default: |
| 2720 | return "fail"; |
| 2721 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2722 | } |
| 2723 | |
| 2724 | static int |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2725 | i965_decode_urb_fence(struct drm_intel_decode *ctx, int len) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2726 | { |
| 2727 | uint32_t vs_fence, clip_fence, gs_fence, sf_fence, vfe_fence, cs_fence; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2728 | uint32_t *data = ctx->data; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2729 | |
| 2730 | if (len != 3) |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2731 | fprintf(out, "Bad count in URB_FENCE\n"); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2732 | |
| 2733 | vs_fence = data[1] & 0x3ff; |
| 2734 | gs_fence = (data[1] >> 10) & 0x3ff; |
| 2735 | clip_fence = (data[1] >> 20) & 0x3ff; |
| 2736 | sf_fence = data[2] & 0x3ff; |
| 2737 | vfe_fence = (data[2] >> 10) & 0x3ff; |
| 2738 | cs_fence = (data[2] >> 20) & 0x7ff; |
| 2739 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2740 | instr_out(ctx, 0, "URB_FENCE: %s%s%s%s%s%s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2741 | (data[0] >> 13) & 1 ? "cs " : "", |
| 2742 | (data[0] >> 12) & 1 ? "vfe " : "", |
| 2743 | (data[0] >> 11) & 1 ? "sf " : "", |
| 2744 | (data[0] >> 10) & 1 ? "clip " : "", |
| 2745 | (data[0] >> 9) & 1 ? "gs " : "", |
| 2746 | (data[0] >> 8) & 1 ? "vs " : ""); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2747 | instr_out(ctx, 1, |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2748 | "vs fence: %d, clip_fence: %d, gs_fence: %d\n", |
| 2749 | vs_fence, clip_fence, gs_fence); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2750 | instr_out(ctx, 2, |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2751 | "sf fence: %d, vfe_fence: %d, cs_fence: %d\n", |
| 2752 | sf_fence, vfe_fence, cs_fence); |
| 2753 | if (gs_fence < vs_fence) |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2754 | fprintf(out, "gs fence < vs fence!\n"); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2755 | if (clip_fence < gs_fence) |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2756 | fprintf(out, "clip fence < gs fence!\n"); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2757 | if (sf_fence < clip_fence) |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2758 | fprintf(out, "sf fence < clip fence!\n"); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2759 | if (cs_fence < sf_fence) |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2760 | fprintf(out, "cs fence < sf fence!\n"); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2761 | |
| 2762 | return len; |
| 2763 | } |
| 2764 | |
| 2765 | static void |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2766 | state_base_out(struct drm_intel_decode *ctx, unsigned int index, |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 2767 | const char *name) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2768 | { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2769 | if (ctx->data[index] & 1) { |
| 2770 | instr_out(ctx, index, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2771 | "%s state base address 0x%08x\n", name, |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2772 | ctx->data[index] & ~1); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2773 | } else { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2774 | instr_out(ctx, index, "%s state base not updated\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2775 | name); |
| 2776 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2777 | } |
| 2778 | |
| 2779 | static void |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2780 | state_max_out(struct drm_intel_decode *ctx, unsigned int index, |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 2781 | const char *name) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2782 | { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2783 | if (ctx->data[index] & 1) { |
| 2784 | if (ctx->data[index] == 1) { |
| 2785 | instr_out(ctx, index, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2786 | "%s state upper bound disabled\n", name); |
| 2787 | } else { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2788 | instr_out(ctx, index, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2789 | "%s state upper bound 0x%08x\n", name, |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2790 | ctx->data[index] & ~1); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2791 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2792 | } else { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 2793 | instr_out(ctx, index, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 2794 | "%s state upper bound not updated\n", name); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2795 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 2796 | } |
| 2797 | |
| 2798 | static int |
Eric Anholt | 938df6b | 2012-01-04 12:23:42 -0800 | [diff] [blame] | 2799 | gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC(struct drm_intel_decode *ctx) |
| 2800 | { |
| 2801 | instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_CC\n"); |
| 2802 | instr_out(ctx, 1, "pointer to CC viewport\n"); |
| 2803 | |
| 2804 | return 2; |
| 2805 | } |
| 2806 | |
| 2807 | static int |
| 2808 | gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP(struct drm_intel_decode *ctx) |
| 2809 | { |
| 2810 | instr_out(ctx, 0, "3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP\n"); |
| 2811 | instr_out(ctx, 1, "pointer to SF_CLIP viewport\n"); |
| 2812 | |
| 2813 | return 2; |
| 2814 | } |
| 2815 | |
| 2816 | static int |
| 2817 | gen7_3DSTATE_BLEND_STATE_POINTERS(struct drm_intel_decode *ctx) |
| 2818 | { |
| 2819 | instr_out(ctx, 0, "3DSTATE_BLEND_STATE_POINTERS\n"); |
| 2820 | instr_out(ctx, 1, "pointer to BLEND_STATE at 0x%08x (%s)\n", |
| 2821 | ctx->data[1] & ~1, |
| 2822 | (ctx->data[1] & 1) ? "changed" : "unchanged"); |
| 2823 | |
| 2824 | return 2; |
| 2825 | } |
| 2826 | |
| 2827 | static int |
| 2828 | gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS(struct drm_intel_decode *ctx) |
| 2829 | { |
| 2830 | instr_out(ctx, 0, "3DSTATE_DEPTH_STENCIL_STATE_POINTERS\n"); |
| 2831 | instr_out(ctx, 1, |
| 2832 | "pointer to DEPTH_STENCIL_STATE at 0x%08x (%s)\n", |
| 2833 | ctx->data[1] & ~1, |
| 2834 | (ctx->data[1] & 1) ? "changed" : "unchanged"); |
| 2835 | |
| 2836 | return 2; |
| 2837 | } |
| 2838 | |
| 2839 | static int |
Eric Anholt | b395af0 | 2012-01-30 15:13:32 -0800 | [diff] [blame] | 2840 | gen7_3DSTATE_HIER_DEPTH_BUFFER(struct drm_intel_decode *ctx) |
| 2841 | { |
| 2842 | instr_out(ctx, 0, "3DSTATE_HIER_DEPTH_BUFFER\n"); |
| 2843 | instr_out(ctx, 1, "pitch %db\n", |
| 2844 | (ctx->data[1] & 0x1ffff) + 1); |
| 2845 | instr_out(ctx, 2, "pointer to HiZ buffer\n"); |
| 2846 | |
| 2847 | return 3; |
| 2848 | } |
| 2849 | |
| 2850 | static int |
Eric Anholt | 938df6b | 2012-01-04 12:23:42 -0800 | [diff] [blame] | 2851 | gen6_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx) |
| 2852 | { |
| 2853 | instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n"); |
| 2854 | instr_out(ctx, 1, "blend change %d\n", ctx->data[1] & 1); |
| 2855 | instr_out(ctx, 2, "depth stencil change %d\n", |
| 2856 | ctx->data[2] & 1); |
| 2857 | instr_out(ctx, 3, "cc change %d\n", ctx->data[3] & 1); |
| 2858 | |
| 2859 | return 4; |
| 2860 | } |
| 2861 | |
| 2862 | static int |
| 2863 | gen7_3DSTATE_CC_STATE_POINTERS(struct drm_intel_decode *ctx) |
| 2864 | { |
| 2865 | instr_out(ctx, 0, "3DSTATE_CC_STATE_POINTERS\n"); |
| 2866 | instr_out(ctx, 1, "pointer to COLOR_CALC_STATE at 0x%08x " |
| 2867 | "(%s)\n", |
| 2868 | ctx->data[1] & ~1, |
| 2869 | (ctx->data[1] & 1) ? "changed" : "unchanged"); |
| 2870 | |
| 2871 | return 2; |
| 2872 | } |
| 2873 | |
| 2874 | static int |
Eric Anholt | 6a0b25e | 2012-01-04 12:12:41 -0800 | [diff] [blame] | 2875 | gen7_3DSTATE_URB_unit(struct drm_intel_decode *ctx, const char *unit) |
| 2876 | { |
| 2877 | int start_kb = ((ctx->data[1] >> 25) & 0x3f) * 8; |
| 2878 | /* the field is # of 512-bit rows - 1, we print bytes */ |
| 2879 | int entry_size = (((ctx->data[1] >> 16) & 0x1ff) + 1); |
| 2880 | int nr_entries = ctx->data[1] & 0xffff; |
| 2881 | |
| 2882 | instr_out(ctx, 0, "3DSTATE_URB_%s\n", unit); |
| 2883 | instr_out(ctx, 1, |
| 2884 | "%dKB start, size=%d 64B rows, nr_entries=%d, total size %dB\n", |
| 2885 | start_kb, entry_size, nr_entries, nr_entries * 64 * entry_size); |
| 2886 | |
| 2887 | return 2; |
| 2888 | } |
| 2889 | |
| 2890 | static int |
| 2891 | gen7_3DSTATE_URB_VS(struct drm_intel_decode *ctx) |
| 2892 | { |
| 2893 | return gen7_3DSTATE_URB_unit(ctx, "VS"); |
| 2894 | } |
| 2895 | |
| 2896 | static int |
| 2897 | gen7_3DSTATE_URB_HS(struct drm_intel_decode *ctx) |
| 2898 | { |
| 2899 | return gen7_3DSTATE_URB_unit(ctx, "HS"); |
| 2900 | } |
| 2901 | |
| 2902 | static int |
| 2903 | gen7_3DSTATE_URB_DS(struct drm_intel_decode *ctx) |
| 2904 | { |
| 2905 | return gen7_3DSTATE_URB_unit(ctx, "DS"); |
| 2906 | } |
| 2907 | |
| 2908 | static int |
| 2909 | gen7_3DSTATE_URB_GS(struct drm_intel_decode *ctx) |
| 2910 | { |
| 2911 | return gen7_3DSTATE_URB_unit(ctx, "GS"); |
| 2912 | } |
| 2913 | |
| 2914 | static int |
Eric Anholt | 54b12a0 | 2012-01-04 13:41:55 -0800 | [diff] [blame] | 2915 | gen7_3DSTATE_CONSTANT(struct drm_intel_decode *ctx, const char *unit) |
| 2916 | { |
| 2917 | int rlen[4]; |
| 2918 | |
| 2919 | rlen[0] = (ctx->data[1] >> 0) & 0xffff; |
| 2920 | rlen[1] = (ctx->data[1] >> 16) & 0xffff; |
| 2921 | rlen[2] = (ctx->data[2] >> 0) & 0xffff; |
| 2922 | rlen[3] = (ctx->data[2] >> 16) & 0xffff; |
| 2923 | |
| 2924 | instr_out(ctx, 0, "3DSTATE_CONSTANT_%s\n", unit); |
| 2925 | instr_out(ctx, 1, "len 0 = %d, len 1 = %d\n", rlen[0], rlen[1]); |
| 2926 | instr_out(ctx, 2, "len 2 = %d, len 3 = %d\n", rlen[2], rlen[3]); |
| 2927 | instr_out(ctx, 3, "pointer to constbuf 0\n"); |
| 2928 | instr_out(ctx, 4, "pointer to constbuf 1\n"); |
| 2929 | instr_out(ctx, 5, "pointer to constbuf 2\n"); |
| 2930 | instr_out(ctx, 6, "pointer to constbuf 3\n"); |
| 2931 | |
| 2932 | return 7; |
| 2933 | } |
| 2934 | |
| 2935 | static int |
| 2936 | gen7_3DSTATE_CONSTANT_VS(struct drm_intel_decode *ctx) |
| 2937 | { |
| 2938 | return gen7_3DSTATE_CONSTANT(ctx, "VS"); |
| 2939 | } |
| 2940 | |
| 2941 | static int |
| 2942 | gen7_3DSTATE_CONSTANT_GS(struct drm_intel_decode *ctx) |
| 2943 | { |
| 2944 | return gen7_3DSTATE_CONSTANT(ctx, "GS"); |
| 2945 | } |
| 2946 | |
| 2947 | static int |
| 2948 | gen7_3DSTATE_CONSTANT_PS(struct drm_intel_decode *ctx) |
| 2949 | { |
| 2950 | return gen7_3DSTATE_CONSTANT(ctx, "PS"); |
| 2951 | } |
| 2952 | |
| 2953 | static int |
| 2954 | gen7_3DSTATE_CONSTANT_DS(struct drm_intel_decode *ctx) |
| 2955 | { |
| 2956 | return gen7_3DSTATE_CONSTANT(ctx, "DS"); |
| 2957 | } |
| 2958 | |
| 2959 | static int |
| 2960 | gen7_3DSTATE_CONSTANT_HS(struct drm_intel_decode *ctx) |
| 2961 | { |
| 2962 | return gen7_3DSTATE_CONSTANT(ctx, "HS"); |
| 2963 | } |
| 2964 | |
Eric Anholt | e6beaf8 | 2012-01-30 15:04:10 -0800 | [diff] [blame] | 2965 | |
| 2966 | static int |
| 2967 | gen6_3DSTATE_WM(struct drm_intel_decode *ctx) |
| 2968 | { |
| 2969 | instr_out(ctx, 0, "3DSTATE_WM\n"); |
| 2970 | instr_out(ctx, 1, "kernel start pointer 0\n"); |
| 2971 | instr_out(ctx, 2, |
| 2972 | "SPF=%d, VME=%d, Sampler Count %d, " |
| 2973 | "Binding table count %d\n", |
| 2974 | (ctx->data[2] >> 31) & 1, |
| 2975 | (ctx->data[2] >> 30) & 1, |
| 2976 | (ctx->data[2] >> 27) & 7, |
| 2977 | (ctx->data[2] >> 18) & 0xff); |
| 2978 | instr_out(ctx, 3, "scratch offset\n"); |
| 2979 | instr_out(ctx, 4, |
| 2980 | "Depth Clear %d, Depth Resolve %d, HiZ Resolve %d, " |
| 2981 | "Dispatch GRF start[0] %d, start[1] %d, start[2] %d\n", |
| 2982 | (ctx->data[4] & (1 << 30)) != 0, |
| 2983 | (ctx->data[4] & (1 << 28)) != 0, |
| 2984 | (ctx->data[4] & (1 << 27)) != 0, |
| 2985 | (ctx->data[4] >> 16) & 0x7f, |
| 2986 | (ctx->data[4] >> 8) & 0x7f, |
| 2987 | (ctx->data[4] & 0x7f)); |
| 2988 | instr_out(ctx, 5, |
| 2989 | "MaxThreads %d, PS KillPixel %d, PS computed Z %d, " |
| 2990 | "PS use sourceZ %d, Thread Dispatch %d, PS use sourceW %d, " |
| 2991 | "Dispatch32 %d, Dispatch16 %d, Dispatch8 %d\n", |
| 2992 | ((ctx->data[5] >> 25) & 0x7f) + 1, |
| 2993 | (ctx->data[5] & (1 << 22)) != 0, |
| 2994 | (ctx->data[5] & (1 << 21)) != 0, |
| 2995 | (ctx->data[5] & (1 << 20)) != 0, |
| 2996 | (ctx->data[5] & (1 << 19)) != 0, |
| 2997 | (ctx->data[5] & (1 << 8)) != 0, |
| 2998 | (ctx->data[5] & (1 << 2)) != 0, |
| 2999 | (ctx->data[5] & (1 << 1)) != 0, |
| 3000 | (ctx->data[5] & (1 << 0)) != 0); |
| 3001 | instr_out(ctx, 6, |
| 3002 | "Num SF output %d, Pos XY offset %d, ZW interp mode %d , " |
| 3003 | "Barycentric interp mode 0x%x, Point raster rule %d, " |
| 3004 | "Multisample mode %d, " |
| 3005 | "Multisample Dispatch mode %d\n", |
| 3006 | (ctx->data[6] >> 20) & 0x3f, |
| 3007 | (ctx->data[6] >> 18) & 3, |
| 3008 | (ctx->data[6] >> 16) & 3, |
| 3009 | (ctx->data[6] >> 10) & 0x3f, |
| 3010 | (ctx->data[6] & (1 << 9)) != 0, |
| 3011 | (ctx->data[6] >> 1) & 3, |
| 3012 | (ctx->data[6] & 1)); |
| 3013 | instr_out(ctx, 7, "kernel start pointer 1\n"); |
| 3014 | instr_out(ctx, 8, "kernel start pointer 2\n"); |
| 3015 | |
| 3016 | return 9; |
| 3017 | } |
| 3018 | |
| 3019 | static int |
| 3020 | gen7_3DSTATE_WM(struct drm_intel_decode *ctx) |
| 3021 | { |
| 3022 | const char *computed_depth = ""; |
| 3023 | const char *early_depth = ""; |
| 3024 | const char *zw_interp = ""; |
| 3025 | |
| 3026 | switch ((ctx->data[1] >> 23) & 0x3) { |
| 3027 | case 0: |
| 3028 | computed_depth = ""; |
| 3029 | break; |
| 3030 | case 1: |
| 3031 | computed_depth = "computed depth"; |
| 3032 | break; |
| 3033 | case 2: |
| 3034 | computed_depth = "computed depth >="; |
| 3035 | break; |
| 3036 | case 3: |
| 3037 | computed_depth = "computed depth <="; |
| 3038 | break; |
| 3039 | } |
| 3040 | |
| 3041 | switch ((ctx->data[1] >> 21) & 0x3) { |
| 3042 | case 0: |
| 3043 | early_depth = ""; |
| 3044 | break; |
| 3045 | case 1: |
| 3046 | early_depth = ", EDSC_PSEXEC"; |
| 3047 | break; |
| 3048 | case 2: |
| 3049 | early_depth = ", EDSC_PREPS"; |
| 3050 | break; |
| 3051 | case 3: |
| 3052 | early_depth = ", BAD EDSC"; |
| 3053 | break; |
| 3054 | } |
| 3055 | |
| 3056 | switch ((ctx->data[1] >> 17) & 0x3) { |
| 3057 | case 0: |
| 3058 | early_depth = ""; |
| 3059 | break; |
| 3060 | case 1: |
| 3061 | early_depth = ", BAD ZW interp"; |
| 3062 | break; |
| 3063 | case 2: |
| 3064 | early_depth = ", ZW centroid"; |
| 3065 | break; |
| 3066 | case 3: |
| 3067 | early_depth = ", ZW sample"; |
| 3068 | break; |
| 3069 | } |
| 3070 | |
| 3071 | instr_out(ctx, 0, "3DSTATE_WM\n"); |
| 3072 | instr_out(ctx, 1, "(%s%s%s%s%s%s)%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", |
| 3073 | (ctx->data[1] & (1 << 11)) ? "PP " : "", |
| 3074 | (ctx->data[1] & (1 << 12)) ? "PC " : "", |
| 3075 | (ctx->data[1] & (1 << 13)) ? "PS " : "", |
| 3076 | (ctx->data[1] & (1 << 14)) ? "NPP " : "", |
| 3077 | (ctx->data[1] & (1 << 15)) ? "NPC " : "", |
| 3078 | (ctx->data[1] & (1 << 16)) ? "NPS " : "", |
| 3079 | (ctx->data[1] & (1 << 30)) ? ", depth clear" : "", |
| 3080 | (ctx->data[1] & (1 << 29)) ? "" : ", disabled", |
| 3081 | (ctx->data[1] & (1 << 28)) ? ", depth resolve" : "", |
| 3082 | (ctx->data[1] & (1 << 27)) ? ", hiz resolve" : "", |
| 3083 | (ctx->data[1] & (1 << 25)) ? ", kill" : "", |
| 3084 | computed_depth, |
| 3085 | early_depth, |
| 3086 | zw_interp, |
| 3087 | (ctx->data[1] & (1 << 20)) ? ", source depth" : "", |
| 3088 | (ctx->data[1] & (1 << 19)) ? ", source W" : "", |
| 3089 | (ctx->data[1] & (1 << 10)) ? ", coverage" : "", |
| 3090 | (ctx->data[1] & (1 << 4)) ? ", poly stipple" : "", |
| 3091 | (ctx->data[1] & (1 << 3)) ? ", line stipple" : "", |
| 3092 | (ctx->data[1] & (1 << 2)) ? ", point UL" : ", point UR" |
| 3093 | ); |
| 3094 | instr_out(ctx, 2, "MS\n"); |
| 3095 | |
| 3096 | return 3; |
| 3097 | } |
| 3098 | |
Eric Anholt | 54b12a0 | 2012-01-04 13:41:55 -0800 | [diff] [blame] | 3099 | static int |
Eric Anholt | 9b87fd9 | 2012-03-02 10:18:51 -0800 | [diff] [blame] | 3100 | gen4_3DPRIMITIVE(struct drm_intel_decode *ctx) |
| 3101 | { |
| 3102 | instr_out(ctx, 0, |
| 3103 | "3DPRIMITIVE: %s %s\n", |
Eric Anholt | 9d18ad2 | 2012-03-02 10:27:55 -0800 | [diff] [blame] | 3104 | get_965_prim_type((ctx->data[0] >> 10) & 0x1f), |
Eric Anholt | 9b87fd9 | 2012-03-02 10:18:51 -0800 | [diff] [blame] | 3105 | (ctx->data[0] & (1 << 15)) ? "random" : "sequential"); |
| 3106 | instr_out(ctx, 1, "vertex count\n"); |
| 3107 | instr_out(ctx, 2, "start vertex\n"); |
| 3108 | instr_out(ctx, 3, "instance count\n"); |
| 3109 | instr_out(ctx, 4, "start instance\n"); |
| 3110 | instr_out(ctx, 5, "index bias\n"); |
| 3111 | |
| 3112 | return 6; |
| 3113 | } |
| 3114 | |
| 3115 | static int |
Eric Anholt | 9d18ad2 | 2012-03-02 10:27:55 -0800 | [diff] [blame] | 3116 | gen7_3DPRIMITIVE(struct drm_intel_decode *ctx) |
| 3117 | { |
| 3118 | bool indirect = !!(ctx->data[0] & (1 << 10)); |
| 3119 | |
| 3120 | instr_out(ctx, 0, |
| 3121 | "3DPRIMITIVE: %s%s\n", |
| 3122 | indirect ? " indirect" : "", |
| 3123 | (ctx->data[0] & (1 << 8)) ? " predicated" : ""); |
| 3124 | instr_out(ctx, 1, "%s %s\n", |
| 3125 | get_965_prim_type(ctx->data[1] & 0x3f), |
| 3126 | (ctx->data[1] & (1 << 8)) ? "random" : "sequential"); |
| 3127 | instr_out(ctx, 2, indirect ? "ignored" : "vertex count\n"); |
| 3128 | instr_out(ctx, 3, indirect ? "ignored" : "start vertex\n"); |
| 3129 | instr_out(ctx, 4, indirect ? "ignored" : "instance count\n"); |
| 3130 | instr_out(ctx, 5, indirect ? "ignored" : "start instance\n"); |
| 3131 | instr_out(ctx, 6, indirect ? "ignored" : "index bias\n"); |
| 3132 | |
| 3133 | return 7; |
| 3134 | } |
| 3135 | |
| 3136 | static int |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3137 | decode_3d_965(struct drm_intel_decode *ctx) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3138 | { |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3139 | uint32_t opcode; |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3140 | unsigned int len; |
Eric Anholt | 7b48318 | 2011-12-20 14:27:17 -0800 | [diff] [blame] | 3141 | unsigned int i, j, sba_len; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 3142 | const char *desc1 = NULL; |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3143 | uint32_t *data = ctx->data; |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3144 | uint32_t devid = ctx->devid; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3145 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3146 | struct { |
| 3147 | uint32_t opcode; |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3148 | uint32_t len_mask; |
Eric Anholt | 07768ba | 2011-12-20 13:46:23 -0800 | [diff] [blame] | 3149 | int unsigned min_len; |
| 3150 | int unsigned max_len; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 3151 | const char *name; |
Eric Anholt | 9695eee | 2012-01-04 12:00:59 -0800 | [diff] [blame] | 3152 | int gen; |
Eric Anholt | 3dcb2d4 | 2012-01-04 12:06:44 -0800 | [diff] [blame] | 3153 | int (*func)(struct drm_intel_decode *ctx); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3154 | } opcodes_3d[] = { |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3155 | { 0x6000, 0x00ff, 3, 3, "URB_FENCE" }, |
| 3156 | { 0x6001, 0xffff, 2, 2, "CS_URB_STATE" }, |
| 3157 | { 0x6002, 0x00ff, 2, 2, "CONSTANT_BUFFER" }, |
Eric Anholt | ba8ce2d | 2012-01-04 13:18:42 -0800 | [diff] [blame] | 3158 | { 0x6101, 0xffff, 6, 10, "STATE_BASE_ADDRESS" }, |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3159 | { 0x6102, 0xffff, 2, 2, "STATE_SIP" }, |
| 3160 | { 0x6104, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" }, |
| 3161 | { 0x680b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" }, |
| 3162 | { 0x6904, 0xffff, 1, 1, "3DSTATE_PIPELINE_SELECT" }, |
| 3163 | { 0x7800, 0xffff, 7, 7, "3DSTATE_PIPELINED_POINTERS" }, |
Eric Anholt | ba8ce2d | 2012-01-04 13:18:42 -0800 | [diff] [blame] | 3164 | { 0x7801, 0x00ff, 4, 6, "3DSTATE_BINDING_TABLE_POINTERS" }, |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3165 | { 0x7802, 0x00ff, 4, 4, "3DSTATE_SAMPLER_STATE_POINTERS" }, |
Eric Anholt | b643b07 | 2012-01-04 14:36:13 -0800 | [diff] [blame] | 3166 | { 0x7805, 0x00ff, 7, 7, "3DSTATE_DEPTH_BUFFER", 7 }, |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3167 | { 0x7805, 0x00ff, 3, 3, "3DSTATE_URB" }, |
Eric Anholt | b643b07 | 2012-01-04 14:36:13 -0800 | [diff] [blame] | 3168 | { 0x7804, 0x00ff, 3, 3, "3DSTATE_CLEAR_PARAMS" }, |
| 3169 | { 0x7806, 0x00ff, 3, 3, "3DSTATE_STENCIL_BUFFER" }, |
Daniel Vetter | b7bb9e9 | 2013-04-03 18:25:12 +0200 | [diff] [blame] | 3170 | { 0x790f, 0x00ff, 3, 3, "3DSTATE_HIER_DEPTH_BUFFER", 6 }, |
Eric Anholt | b395af0 | 2012-01-30 15:13:32 -0800 | [diff] [blame] | 3171 | { 0x7807, 0x00ff, 3, 3, "3DSTATE_HIER_DEPTH_BUFFER", 7, gen7_3DSTATE_HIER_DEPTH_BUFFER }, |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3172 | { 0x7808, 0x00ff, 5, 257, "3DSTATE_VERTEX_BUFFERS" }, |
| 3173 | { 0x7809, 0x00ff, 3, 256, "3DSTATE_VERTEX_ELEMENTS" }, |
| 3174 | { 0x780a, 0x00ff, 3, 3, "3DSTATE_INDEX_BUFFER" }, |
| 3175 | { 0x780b, 0xffff, 1, 1, "3DSTATE_VF_STATISTICS" }, |
| 3176 | { 0x780d, 0x00ff, 4, 4, "3DSTATE_VIEWPORT_STATE_POINTERS" }, |
Eric Anholt | 938df6b | 2012-01-04 12:23:42 -0800 | [diff] [blame] | 3177 | { 0x780e, 0xffff, 4, 4, NULL, 6, gen6_3DSTATE_CC_STATE_POINTERS }, |
| 3178 | { 0x780e, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_CC_STATE_POINTERS }, |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3179 | { 0x780f, 0x00ff, 2, 2, "3DSTATE_SCISSOR_POINTERS" }, |
| 3180 | { 0x7810, 0x00ff, 6, 6, "3DSTATE_VS" }, |
| 3181 | { 0x7811, 0x00ff, 7, 7, "3DSTATE_GS" }, |
| 3182 | { 0x7812, 0x00ff, 4, 4, "3DSTATE_CLIP" }, |
Eric Anholt | b643b07 | 2012-01-04 14:36:13 -0800 | [diff] [blame] | 3183 | { 0x7813, 0x00ff, 20, 20, "3DSTATE_SF", 6 }, |
| 3184 | { 0x7813, 0x00ff, 7, 7, "3DSTATE_SF", 7 }, |
Eric Anholt | e6beaf8 | 2012-01-30 15:04:10 -0800 | [diff] [blame] | 3185 | { 0x7814, 0x00ff, 3, 3, "3DSTATE_WM", 7, gen7_3DSTATE_WM }, |
| 3186 | { 0x7814, 0x00ff, 9, 9, "3DSTATE_WM", 6, gen6_3DSTATE_WM }, |
Eric Anholt | 54b12a0 | 2012-01-04 13:41:55 -0800 | [diff] [blame] | 3187 | { 0x7815, 0x00ff, 5, 5, "3DSTATE_CONSTANT_VS_STATE", 6 }, |
| 3188 | { 0x7815, 0x00ff, 7, 7, "3DSTATE_CONSTANT_VS", 7, gen7_3DSTATE_CONSTANT_VS }, |
| 3189 | { 0x7816, 0x00ff, 5, 5, "3DSTATE_CONSTANT_GS_STATE", 6 }, |
| 3190 | { 0x7816, 0x00ff, 7, 7, "3DSTATE_CONSTANT_GS", 7, gen7_3DSTATE_CONSTANT_GS }, |
| 3191 | { 0x7817, 0x00ff, 5, 5, "3DSTATE_CONSTANT_PS_STATE", 6 }, |
| 3192 | { 0x7817, 0x00ff, 7, 7, "3DSTATE_CONSTANT_PS", 7, gen7_3DSTATE_CONSTANT_PS }, |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3193 | { 0x7818, 0xffff, 2, 2, "3DSTATE_SAMPLE_MASK" }, |
Eric Anholt | 54b12a0 | 2012-01-04 13:41:55 -0800 | [diff] [blame] | 3194 | { 0x7819, 0x00ff, 7, 7, "3DSTATE_CONSTANT_HS", 7, gen7_3DSTATE_CONSTANT_HS }, |
| 3195 | { 0x781a, 0x00ff, 7, 7, "3DSTATE_CONSTANT_DS", 7, gen7_3DSTATE_CONSTANT_DS }, |
Eric Anholt | b643b07 | 2012-01-04 14:36:13 -0800 | [diff] [blame] | 3196 | { 0x781b, 0x00ff, 7, 7, "3DSTATE_HS" }, |
| 3197 | { 0x781c, 0x00ff, 4, 4, "3DSTATE_TE" }, |
| 3198 | { 0x781d, 0x00ff, 6, 6, "3DSTATE_DS" }, |
| 3199 | { 0x781e, 0x00ff, 3, 3, "3DSTATE_STREAMOUT" }, |
| 3200 | { 0x781f, 0x00ff, 14, 14, "3DSTATE_SBE" }, |
| 3201 | { 0x7820, 0x00ff, 8, 8, "3DSTATE_PS" }, |
Eric Anholt | 938df6b | 2012-01-04 12:23:42 -0800 | [diff] [blame] | 3202 | { 0x7821, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP }, |
| 3203 | { 0x7823, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_VIEWPORT_STATE_POINTERS_CC }, |
| 3204 | { 0x7824, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_BLEND_STATE_POINTERS }, |
| 3205 | { 0x7825, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_DEPTH_STENCIL_STATE_POINTERS }, |
Eric Anholt | b643b07 | 2012-01-04 14:36:13 -0800 | [diff] [blame] | 3206 | { 0x7826, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_VS" }, |
| 3207 | { 0x7827, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_HS" }, |
| 3208 | { 0x7828, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_DS" }, |
| 3209 | { 0x7829, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_GS" }, |
| 3210 | { 0x782a, 0x00ff, 2, 2, "3DSTATE_BINDING_TABLE_POINTERS_PS" }, |
| 3211 | { 0x782b, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_VS" }, |
Ben Widawsky | eeedb0d | 2012-06-24 21:53:50 -0700 | [diff] [blame] | 3212 | { 0x782c, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_HS" }, |
| 3213 | { 0x782d, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_DS" }, |
Eric Anholt | b643b07 | 2012-01-04 14:36:13 -0800 | [diff] [blame] | 3214 | { 0x782e, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_GS" }, |
| 3215 | { 0x782f, 0x00ff, 2, 2, "3DSTATE_SAMPLER_STATE_POINTERS_PS" }, |
Eric Anholt | 6a0b25e | 2012-01-04 12:12:41 -0800 | [diff] [blame] | 3216 | { 0x7830, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_VS }, |
| 3217 | { 0x7831, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_HS }, |
| 3218 | { 0x7832, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_DS }, |
| 3219 | { 0x7833, 0x00ff, 2, 2, NULL, 7, gen7_3DSTATE_URB_GS }, |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3220 | { 0x7900, 0xffff, 4, 4, "3DSTATE_DRAWING_RECTANGLE" }, |
| 3221 | { 0x7901, 0xffff, 5, 5, "3DSTATE_CONSTANT_COLOR" }, |
| 3222 | { 0x7905, 0xffff, 5, 7, "3DSTATE_DEPTH_BUFFER" }, |
| 3223 | { 0x7906, 0xffff, 2, 2, "3DSTATE_POLY_STIPPLE_OFFSET" }, |
| 3224 | { 0x7907, 0xffff, 33, 33, "3DSTATE_POLY_STIPPLE_PATTERN" }, |
| 3225 | { 0x7908, 0xffff, 3, 3, "3DSTATE_LINE_STIPPLE" }, |
| 3226 | { 0x7909, 0xffff, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" }, |
| 3227 | { 0x7909, 0xffff, 2, 2, "3DSTATE_CLEAR_PARAMS" }, |
| 3228 | { 0x790a, 0xffff, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" }, |
| 3229 | { 0x790b, 0xffff, 4, 4, "3DSTATE_GS_SVB_INDEX" }, |
| 3230 | { 0x790d, 0xffff, 3, 3, "3DSTATE_MULTISAMPLE", 6 }, |
| 3231 | { 0x790d, 0xffff, 4, 4, "3DSTATE_MULTISAMPLE", 7 }, |
Chris Forbes | 20c5607 | 2013-01-28 08:01:18 +0000 | [diff] [blame] | 3232 | { 0x7910, 0x00ff, 2, 2, "3DSTATE_CLEAR_PARAMS" }, |
Eric Anholt | b643b07 | 2012-01-04 14:36:13 -0800 | [diff] [blame] | 3233 | { 0x7912, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_VS" }, |
Ben Widawsky | ae137f4 | 2012-06-24 17:12:24 -0700 | [diff] [blame] | 3234 | { 0x7913, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_HS" }, |
| 3235 | { 0x7914, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_DS" }, |
| 3236 | { 0x7915, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_GS" }, |
Eric Anholt | b643b07 | 2012-01-04 14:36:13 -0800 | [diff] [blame] | 3237 | { 0x7916, 0x00ff, 2, 2, "3DSTATE_PUSH_CONSTANT_ALLOC_PS" }, |
| 3238 | { 0x7917, 0x00ff, 2, 2+128*2, "3DSTATE_SO_DECL_LIST" }, |
| 3239 | { 0x7918, 0x00ff, 4, 4, "3DSTATE_SO_BUFFER" }, |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3240 | { 0x7a00, 0x00ff, 4, 6, "PIPE_CONTROL" }, |
Eric Anholt | 9d18ad2 | 2012-03-02 10:27:55 -0800 | [diff] [blame] | 3241 | { 0x7b00, 0x00ff, 7, 7, NULL, 7, gen7_3DPRIMITIVE }, |
Eric Anholt | 9b87fd9 | 2012-03-02 10:18:51 -0800 | [diff] [blame] | 3242 | { 0x7b00, 0x00ff, 6, 6, NULL, 0, gen4_3DPRIMITIVE }, |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3243 | }, *opcode_3d = NULL; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3244 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3245 | opcode = (data[0] & 0xffff0000) >> 16; |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3246 | |
| 3247 | for (i = 0; i < ARRAY_SIZE(opcodes_3d); i++) { |
| 3248 | if (opcode != opcodes_3d[i].opcode) |
| 3249 | continue; |
| 3250 | |
| 3251 | /* If it's marked as not our gen, skip. */ |
| 3252 | if (opcodes_3d[i].gen && opcodes_3d[i].gen != ctx->gen) |
| 3253 | continue; |
| 3254 | |
| 3255 | opcode_3d = &opcodes_3d[i]; |
| 3256 | break; |
| 3257 | } |
| 3258 | |
| 3259 | if (opcode_3d) { |
| 3260 | if (opcode_3d->max_len == 1) |
| 3261 | len = 1; |
| 3262 | else |
| 3263 | len = (data[0] & opcode_3d->len_mask) + 2; |
Eric Anholt | ba8ce2d | 2012-01-04 13:18:42 -0800 | [diff] [blame] | 3264 | |
| 3265 | if (len < opcode_3d->min_len || |
| 3266 | len > opcode_3d->max_len) { |
Eric Anholt | 259e7b6 | 2012-01-27 13:27:56 -0800 | [diff] [blame] | 3267 | fprintf(out, "Bad length %d in %s, expected %d-%d\n", |
Eric Anholt | ba8ce2d | 2012-01-04 13:18:42 -0800 | [diff] [blame] | 3268 | len, opcode_3d->name, |
| 3269 | opcode_3d->min_len, opcode_3d->max_len); |
| 3270 | } |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3271 | } else { |
| 3272 | len = (data[0] & 0x0000ffff) + 2; |
| 3273 | } |
| 3274 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3275 | switch (opcode) { |
| 3276 | case 0x6000: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3277 | return i965_decode_urb_fence(ctx, len); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3278 | case 0x6001: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3279 | instr_out(ctx, 0, "CS_URB_STATE\n"); |
| 3280 | instr_out(ctx, 1, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3281 | "entry_size: %d [%d bytes], n_entries: %d\n", |
| 3282 | (data[1] >> 4) & 0x1f, |
| 3283 | (((data[1] >> 4) & 0x1f) + 1) * 64, data[1] & 0x7); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3284 | return len; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3285 | case 0x6002: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3286 | instr_out(ctx, 0, "CONSTANT_BUFFER: %s\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3287 | (data[0] >> 8) & 1 ? "valid" : "invalid"); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3288 | instr_out(ctx, 1, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3289 | "offset: 0x%08x, length: %d bytes\n", data[1] & ~0x3f, |
| 3290 | ((data[1] & 0x3f) + 1) * 64); |
| 3291 | return len; |
| 3292 | case 0x6101: |
| 3293 | i = 0; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3294 | instr_out(ctx, 0, "STATE_BASE_ADDRESS\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3295 | i++; |
| 3296 | |
| 3297 | if (IS_GEN6(devid) || IS_GEN7(devid)) |
| 3298 | sba_len = 10; |
| 3299 | else if (IS_GEN5(devid)) |
| 3300 | sba_len = 8; |
| 3301 | else |
| 3302 | sba_len = 6; |
| 3303 | if (len != sba_len) |
| 3304 | fprintf(out, "Bad count in STATE_BASE_ADDRESS\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3305 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3306 | state_base_out(ctx, i++, "general"); |
| 3307 | state_base_out(ctx, i++, "surface"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3308 | if (IS_GEN6(devid) || IS_GEN7(devid)) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3309 | state_base_out(ctx, i++, "dynamic"); |
| 3310 | state_base_out(ctx, i++, "indirect"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3311 | if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid)) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3312 | state_base_out(ctx, i++, "instruction"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3313 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3314 | state_max_out(ctx, i++, "general"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3315 | if (IS_GEN6(devid) || IS_GEN7(devid)) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3316 | state_max_out(ctx, i++, "dynamic"); |
| 3317 | state_max_out(ctx, i++, "indirect"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3318 | if (IS_GEN5(devid) || IS_GEN6(devid) || IS_GEN7(devid)) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3319 | state_max_out(ctx, i++, "instruction"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3320 | |
| 3321 | return len; |
| 3322 | case 0x7800: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3323 | instr_out(ctx, 0, "3DSTATE_PIPELINED_POINTERS\n"); |
| 3324 | instr_out(ctx, 1, "VS state\n"); |
| 3325 | instr_out(ctx, 2, "GS state\n"); |
| 3326 | instr_out(ctx, 3, "Clip state\n"); |
| 3327 | instr_out(ctx, 4, "SF state\n"); |
| 3328 | instr_out(ctx, 5, "WM state\n"); |
| 3329 | instr_out(ctx, 6, "CC state\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3330 | return len; |
| 3331 | case 0x7801: |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3332 | if (len != 6 && len != 4) |
| 3333 | fprintf(out, |
| 3334 | "Bad count in 3DSTATE_BINDING_TABLE_POINTERS\n"); |
| 3335 | if (len == 6) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3336 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3337 | "3DSTATE_BINDING_TABLE_POINTERS\n"); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3338 | instr_out(ctx, 1, "VS binding table\n"); |
| 3339 | instr_out(ctx, 2, "GS binding table\n"); |
| 3340 | instr_out(ctx, 3, "Clip binding table\n"); |
| 3341 | instr_out(ctx, 4, "SF binding table\n"); |
| 3342 | instr_out(ctx, 5, "WM binding table\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3343 | } else { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3344 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3345 | "3DSTATE_BINDING_TABLE_POINTERS: VS mod %d, " |
| 3346 | "GS mod %d, PS mod %d\n", |
| 3347 | (data[0] & (1 << 8)) != 0, |
| 3348 | (data[0] & (1 << 9)) != 0, |
| 3349 | (data[0] & (1 << 12)) != 0); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3350 | instr_out(ctx, 1, "VS binding table\n"); |
| 3351 | instr_out(ctx, 2, "GS binding table\n"); |
| 3352 | instr_out(ctx, 3, "WM binding table\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3353 | } |
| 3354 | |
| 3355 | return len; |
| 3356 | case 0x7802: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3357 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3358 | "3DSTATE_SAMPLER_STATE_POINTERS: VS mod %d, " |
| 3359 | "GS mod %d, PS mod %d\n", (data[0] & (1 << 8)) != 0, |
| 3360 | (data[0] & (1 << 9)) != 0, |
| 3361 | (data[0] & (1 << 12)) != 0); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3362 | instr_out(ctx, 1, "VS sampler state\n"); |
| 3363 | instr_out(ctx, 2, "GS sampler state\n"); |
| 3364 | instr_out(ctx, 3, "WM sampler state\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3365 | return len; |
| 3366 | case 0x7805: |
Eric Anholt | b643b07 | 2012-01-04 14:36:13 -0800 | [diff] [blame] | 3367 | /* Actually 3DSTATE_DEPTH_BUFFER on gen7. */ |
| 3368 | if (ctx->gen == 7) |
| 3369 | break; |
| 3370 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3371 | instr_out(ctx, 0, "3DSTATE_URB\n"); |
| 3372 | instr_out(ctx, 1, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3373 | "VS entries %d, alloc size %d (1024bit row)\n", |
| 3374 | data[1] & 0xffff, ((data[1] >> 16) & 0x07f) + 1); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3375 | instr_out(ctx, 2, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3376 | "GS entries %d, alloc size %d (1024bit row)\n", |
| 3377 | (data[2] >> 8) & 0x3ff, (data[2] & 7) + 1); |
| 3378 | return len; |
| 3379 | |
| 3380 | case 0x7808: |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3381 | if ((len - 1) % 4 != 0) |
| 3382 | fprintf(out, "Bad count in 3DSTATE_VERTEX_BUFFERS\n"); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3383 | instr_out(ctx, 0, "3DSTATE_VERTEX_BUFFERS\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3384 | |
| 3385 | for (i = 1; i < len;) { |
| 3386 | int idx, access; |
| 3387 | if (IS_GEN6(devid)) { |
| 3388 | idx = 26; |
| 3389 | access = 20; |
| 3390 | } else { |
| 3391 | idx = 27; |
| 3392 | access = 26; |
| 3393 | } |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3394 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3395 | "buffer %d: %s, pitch %db\n", data[i] >> idx, |
| 3396 | data[i] & (1 << access) ? "random" : |
| 3397 | "sequential", data[i] & 0x07ff); |
| 3398 | i++; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3399 | instr_out(ctx, i++, "buffer address\n"); |
| 3400 | instr_out(ctx, i++, "max index\n"); |
| 3401 | instr_out(ctx, i++, "mbz\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3402 | } |
| 3403 | return len; |
| 3404 | |
| 3405 | case 0x7809: |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3406 | if ((len + 1) % 2 != 0) |
| 3407 | fprintf(out, "Bad count in 3DSTATE_VERTEX_ELEMENTS\n"); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3408 | instr_out(ctx, 0, "3DSTATE_VERTEX_ELEMENTS\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3409 | |
| 3410 | for (i = 1; i < len;) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3411 | instr_out(ctx, i, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3412 | "buffer %d: %svalid, type 0x%04x, " |
| 3413 | "src offset 0x%04x bytes\n", |
Ben Widawsky | a780519 | 2012-06-27 10:10:53 -0700 | [diff] [blame] | 3414 | data[i] >> ((IS_GEN6(devid) || IS_GEN7(devid)) ? 26 : 27), |
| 3415 | data[i] & (1 << ((IS_GEN6(devid) || IS_GEN7(devid)) ? 25 : 26)) ? |
Ben Widawsky | df5cc69 | 2012-06-27 10:19:49 -0700 | [diff] [blame] | 3416 | "" : "in", (data[i] >> 16) & 0x1ff, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3417 | data[i] & 0x07ff); |
| 3418 | i++; |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3419 | instr_out(ctx, i, "(%s, %s, %s, %s), " |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3420 | "dst offset 0x%02x bytes\n", |
| 3421 | get_965_element_component(data[i], 0), |
| 3422 | get_965_element_component(data[i], 1), |
| 3423 | get_965_element_component(data[i], 2), |
| 3424 | get_965_element_component(data[i], 3), |
| 3425 | (data[i] & 0xff) * 4); |
| 3426 | i++; |
| 3427 | } |
| 3428 | return len; |
| 3429 | |
| 3430 | case 0x780d: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3431 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3432 | "3DSTATE_VIEWPORT_STATE_POINTERS\n"); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3433 | instr_out(ctx, 1, "clip\n"); |
| 3434 | instr_out(ctx, 2, "sf\n"); |
| 3435 | instr_out(ctx, 3, "cc\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3436 | return len; |
| 3437 | |
| 3438 | case 0x780a: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3439 | instr_out(ctx, 0, "3DSTATE_INDEX_BUFFER\n"); |
| 3440 | instr_out(ctx, 1, "beginning buffer address\n"); |
| 3441 | instr_out(ctx, 2, "ending buffer address\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3442 | return len; |
| 3443 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3444 | case 0x780f: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3445 | instr_out(ctx, 0, "3DSTATE_SCISSOR_POINTERS\n"); |
| 3446 | instr_out(ctx, 1, "scissor rect offset\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3447 | return len; |
| 3448 | |
| 3449 | case 0x7810: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3450 | instr_out(ctx, 0, "3DSTATE_VS\n"); |
| 3451 | instr_out(ctx, 1, "kernel pointer\n"); |
| 3452 | instr_out(ctx, 2, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3453 | "SPF=%d, VME=%d, Sampler Count %d, " |
| 3454 | "Binding table count %d\n", (data[2] >> 31) & 1, |
| 3455 | (data[2] >> 30) & 1, (data[2] >> 27) & 7, |
| 3456 | (data[2] >> 18) & 0xff); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3457 | instr_out(ctx, 3, "scratch offset\n"); |
| 3458 | instr_out(ctx, 4, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3459 | "Dispatch GRF start %d, VUE read length %d, " |
| 3460 | "VUE read offset %d\n", (data[4] >> 20) & 0x1f, |
| 3461 | (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3462 | instr_out(ctx, 5, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3463 | "Max Threads %d, Vertex Cache %sable, " |
| 3464 | "VS func %sable\n", ((data[5] >> 25) & 0x7f) + 1, |
| 3465 | (data[5] & (1 << 1)) != 0 ? "dis" : "en", |
| 3466 | (data[5] & 1) != 0 ? "en" : "dis"); |
| 3467 | return len; |
| 3468 | |
| 3469 | case 0x7811: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3470 | instr_out(ctx, 0, "3DSTATE_GS\n"); |
| 3471 | instr_out(ctx, 1, "kernel pointer\n"); |
| 3472 | instr_out(ctx, 2, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3473 | "SPF=%d, VME=%d, Sampler Count %d, " |
| 3474 | "Binding table count %d\n", (data[2] >> 31) & 1, |
| 3475 | (data[2] >> 30) & 1, (data[2] >> 27) & 7, |
| 3476 | (data[2] >> 18) & 0xff); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3477 | instr_out(ctx, 3, "scratch offset\n"); |
| 3478 | instr_out(ctx, 4, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3479 | "Dispatch GRF start %d, VUE read length %d, " |
| 3480 | "VUE read offset %d\n", (data[4] & 0xf), |
| 3481 | (data[4] >> 11) & 0x3f, (data[4] >> 4) & 0x3f); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3482 | instr_out(ctx, 5, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3483 | "Max Threads %d, Rendering %sable\n", |
| 3484 | ((data[5] >> 25) & 0x7f) + 1, |
| 3485 | (data[5] & (1 << 8)) != 0 ? "en" : "dis"); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3486 | instr_out(ctx, 6, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3487 | "Reorder %sable, Discard Adjaceny %sable, " |
| 3488 | "GS %sable\n", |
| 3489 | (data[6] & (1 << 30)) != 0 ? "en" : "dis", |
| 3490 | (data[6] & (1 << 29)) != 0 ? "en" : "dis", |
| 3491 | (data[6] & (1 << 15)) != 0 ? "en" : "dis"); |
| 3492 | return len; |
| 3493 | |
| 3494 | case 0x7812: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3495 | instr_out(ctx, 0, "3DSTATE_CLIP\n"); |
| 3496 | instr_out(ctx, 1, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3497 | "UserClip distance cull test mask 0x%x\n", |
| 3498 | data[1] & 0xff); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3499 | instr_out(ctx, 2, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3500 | "Clip %sable, API mode %s, Viewport XY test %sable, " |
| 3501 | "Viewport Z test %sable, Guardband test %sable, Clip mode %d, " |
| 3502 | "Perspective Divide %sable, Non-Perspective Barycentric %sable, " |
| 3503 | "Tri Provoking %d, Line Provoking %d, Trifan Provoking %d\n", |
| 3504 | (data[2] & (1 << 31)) != 0 ? "en" : "dis", |
| 3505 | (data[2] & (1 << 30)) != 0 ? "D3D" : "OGL", |
| 3506 | (data[2] & (1 << 28)) != 0 ? "en" : "dis", |
| 3507 | (data[2] & (1 << 27)) != 0 ? "en" : "dis", |
| 3508 | (data[2] & (1 << 26)) != 0 ? "en" : "dis", |
| 3509 | (data[2] >> 13) & 7, |
| 3510 | (data[2] & (1 << 9)) != 0 ? "dis" : "en", |
| 3511 | (data[2] & (1 << 8)) != 0 ? "en" : "dis", |
| 3512 | (data[2] >> 4) & 3, (data[2] >> 2) & 3, |
| 3513 | (data[2] & 3)); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3514 | instr_out(ctx, 3, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3515 | "Min PointWidth %d, Max PointWidth %d, " |
| 3516 | "Force Zero RTAIndex %sable, Max VPIndex %d\n", |
| 3517 | (data[3] >> 17) & 0x7ff, (data[3] >> 6) & 0x7ff, |
| 3518 | (data[3] & (1 << 5)) != 0 ? "en" : "dis", |
| 3519 | (data[3] & 0xf)); |
| 3520 | return len; |
| 3521 | |
| 3522 | case 0x7813: |
Eric Anholt | b643b07 | 2012-01-04 14:36:13 -0800 | [diff] [blame] | 3523 | if (ctx->gen == 7) |
| 3524 | break; |
| 3525 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3526 | instr_out(ctx, 0, "3DSTATE_SF\n"); |
| 3527 | instr_out(ctx, 1, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3528 | "Attrib Out %d, Attrib Swizzle %sable, VUE read length %d, " |
| 3529 | "VUE read offset %d\n", (data[1] >> 22) & 0x3f, |
| 3530 | (data[1] & (1 << 21)) != 0 ? "en" : "dis", |
| 3531 | (data[1] >> 11) & 0x1f, (data[1] >> 4) & 0x3f); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3532 | instr_out(ctx, 2, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3533 | "Legacy Global DepthBias %sable, FrontFace fill %d, BF fill %d, " |
| 3534 | "VP transform %sable, FrontWinding_%s\n", |
| 3535 | (data[2] & (1 << 11)) != 0 ? "en" : "dis", |
| 3536 | (data[2] >> 5) & 3, (data[2] >> 3) & 3, |
| 3537 | (data[2] & (1 << 1)) != 0 ? "en" : "dis", |
| 3538 | (data[2] & 1) != 0 ? "CCW" : "CW"); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3539 | instr_out(ctx, 3, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3540 | "AA %sable, CullMode %d, Scissor %sable, Multisample m ode %d\n", |
| 3541 | (data[3] & (1 << 31)) != 0 ? "en" : "dis", |
| 3542 | (data[3] >> 29) & 3, |
| 3543 | (data[3] & (1 << 11)) != 0 ? "en" : "dis", |
| 3544 | (data[3] >> 8) & 3); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3545 | instr_out(ctx, 4, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3546 | "Last Pixel %sable, SubPixel Precision %d, Use PixelWidth %d\n", |
| 3547 | (data[4] & (1 << 31)) != 0 ? "en" : "dis", |
| 3548 | (data[4] & (1 << 12)) != 0 ? 4 : 8, |
| 3549 | (data[4] & (1 << 11)) != 0); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3550 | instr_out(ctx, 5, |
Eric Anholt | 0c46f02 | 2011-12-20 14:23:15 -0800 | [diff] [blame] | 3551 | "Global Depth Offset Constant %f\n", |
| 3552 | *(float *)(&data[5])); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3553 | instr_out(ctx, 6, "Global Depth Offset Scale %f\n", |
Eric Anholt | 0c46f02 | 2011-12-20 14:23:15 -0800 | [diff] [blame] | 3554 | *(float *)(&data[6])); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3555 | instr_out(ctx, 7, "Global Depth Offset Clamp %f\n", |
Eric Anholt | 0c46f02 | 2011-12-20 14:23:15 -0800 | [diff] [blame] | 3556 | *(float *)(&data[7])); |
Eric Anholt | 7b48318 | 2011-12-20 14:27:17 -0800 | [diff] [blame] | 3557 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3558 | for (i = 0, j = 0; i < 8; i++, j += 2) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3559 | instr_out(ctx, i + 8, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3560 | "Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, " |
| 3561 | "Source %d); Attrib %d (Override %s%s%s%s, Const Source %d, Swizzle Select %d, Source %d)\n", |
| 3562 | j + 1, |
| 3563 | (data[8 + i] & (1 << 31)) != 0 ? "W" : "", |
| 3564 | (data[8 + i] & (1 << 30)) != 0 ? "Z" : "", |
| 3565 | (data[8 + i] & (1 << 29)) != 0 ? "Y" : "", |
| 3566 | (data[8 + i] & (1 << 28)) != 0 ? "X" : "", |
| 3567 | (data[8 + i] >> 25) & 3, |
| 3568 | (data[8 + i] >> 22) & 3, |
| 3569 | (data[8 + i] >> 16) & 0x1f, j, |
| 3570 | (data[8 + i] & (1 << 15)) != 0 ? "W" : "", |
| 3571 | (data[8 + i] & (1 << 14)) != 0 ? "Z" : "", |
| 3572 | (data[8 + i] & (1 << 13)) != 0 ? "Y" : "", |
| 3573 | (data[8 + i] & (1 << 12)) != 0 ? "X" : "", |
| 3574 | (data[8 + i] >> 9) & 3, |
| 3575 | (data[8 + i] >> 6) & 3, (data[8 + i] & 0x1f)); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3576 | instr_out(ctx, 16, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3577 | "Point Sprite TexCoord Enable\n"); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3578 | instr_out(ctx, 17, "Const Interp Enable\n"); |
| 3579 | instr_out(ctx, 18, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3580 | "Attrib 7-0 WrapShortest Enable\n"); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3581 | instr_out(ctx, 19, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3582 | "Attrib 15-8 WrapShortest Enable\n"); |
| 3583 | |
| 3584 | return len; |
| 3585 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3586 | case 0x7900: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3587 | instr_out(ctx, 0, "3DSTATE_DRAWING_RECTANGLE\n"); |
| 3588 | instr_out(ctx, 1, "top left: %d,%d\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3589 | data[1] & 0xffff, (data[1] >> 16) & 0xffff); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3590 | instr_out(ctx, 2, "bottom right: %d,%d\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3591 | data[2] & 0xffff, (data[2] >> 16) & 0xffff); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3592 | instr_out(ctx, 3, "origin: %d,%d\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3593 | (int)data[3] & 0xffff, ((int)data[3] >> 16) & 0xffff); |
| 3594 | |
| 3595 | return len; |
| 3596 | |
| 3597 | case 0x7905: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3598 | instr_out(ctx, 0, "3DSTATE_DEPTH_BUFFER\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3599 | if (IS_GEN5(devid) || IS_GEN6(devid)) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3600 | instr_out(ctx, 1, |
Eric Engestrom | 723a694 | 2016-04-03 19:48:09 +0100 | [diff] [blame] | 3601 | "%s, %s, pitch = %d bytes, %stiled, HiZ %d, Separate Stencil %d\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3602 | get_965_surfacetype(data[1] >> 29), |
| 3603 | get_965_depthformat((data[1] >> 18) & 0x7), |
| 3604 | (data[1] & 0x0001ffff) + 1, |
| 3605 | data[1] & (1 << 27) ? "" : "not ", |
| 3606 | (data[1] & (1 << 22)) != 0, |
| 3607 | (data[1] & (1 << 21)) != 0); |
| 3608 | else |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3609 | instr_out(ctx, 1, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3610 | "%s, %s, pitch = %d bytes, %stiled\n", |
| 3611 | get_965_surfacetype(data[1] >> 29), |
| 3612 | get_965_depthformat((data[1] >> 18) & 0x7), |
| 3613 | (data[1] & 0x0001ffff) + 1, |
| 3614 | data[1] & (1 << 27) ? "" : "not "); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3615 | instr_out(ctx, 2, "depth offset\n"); |
| 3616 | instr_out(ctx, 3, "%dx%d\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3617 | ((data[3] & 0x0007ffc0) >> 6) + 1, |
| 3618 | ((data[3] & 0xfff80000) >> 19) + 1); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3619 | instr_out(ctx, 4, "volume depth\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3620 | if (len >= 6) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3621 | instr_out(ctx, 5, "\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3622 | if (len >= 7) { |
| 3623 | if (IS_GEN6(devid)) |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3624 | instr_out(ctx, 6, "\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3625 | else |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3626 | instr_out(ctx, 6, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3627 | "render target view extent\n"); |
| 3628 | } |
| 3629 | |
| 3630 | return len; |
| 3631 | |
| 3632 | case 0x7a00: |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3633 | if (IS_GEN6(devid) || IS_GEN7(devid)) { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3634 | if (len != 4 && len != 5) |
| 3635 | fprintf(out, "Bad count in PIPE_CONTROL\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3636 | |
| 3637 | switch ((data[1] >> 14) & 0x3) { |
| 3638 | case 0: |
| 3639 | desc1 = "no write"; |
| 3640 | break; |
| 3641 | case 1: |
| 3642 | desc1 = "qword write"; |
| 3643 | break; |
| 3644 | case 2: |
| 3645 | desc1 = "PS_DEPTH_COUNT write"; |
| 3646 | break; |
| 3647 | case 3: |
| 3648 | desc1 = "TIMESTAMP write"; |
| 3649 | break; |
| 3650 | } |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3651 | instr_out(ctx, 0, "PIPE_CONTROL\n"); |
| 3652 | instr_out(ctx, 1, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3653 | "%s, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", |
| 3654 | desc1, |
| 3655 | data[1] & (1 << 20) ? "cs stall, " : "", |
| 3656 | data[1] & (1 << 19) ? |
| 3657 | "global snapshot count reset, " : "", |
| 3658 | data[1] & (1 << 18) ? "tlb invalidate, " : "", |
| 3659 | data[1] & (1 << 17) ? "gfdt flush, " : "", |
| 3660 | data[1] & (1 << 17) ? "media state clear, " : |
| 3661 | "", |
| 3662 | data[1] & (1 << 13) ? "depth stall, " : "", |
| 3663 | data[1] & (1 << 12) ? |
| 3664 | "render target cache flush, " : "", |
| 3665 | data[1] & (1 << 11) ? |
| 3666 | "instruction cache invalidate, " : "", |
| 3667 | data[1] & (1 << 10) ? |
| 3668 | "texture cache invalidate, " : "", |
| 3669 | data[1] & (1 << 9) ? |
| 3670 | "indirect state invalidate, " : "", |
| 3671 | data[1] & (1 << 8) ? "notify irq, " : "", |
| 3672 | data[1] & (1 << 7) ? "PIPE_CONTROL flush, " : |
| 3673 | "", |
| 3674 | data[1] & (1 << 6) ? "protect mem app_id, " : |
| 3675 | "", data[1] & (1 << 5) ? "DC flush, " : "", |
| 3676 | data[1] & (1 << 4) ? "vf fetch invalidate, " : |
| 3677 | "", |
| 3678 | data[1] & (1 << 3) ? |
| 3679 | "constant cache invalidate, " : "", |
| 3680 | data[1] & (1 << 2) ? |
| 3681 | "state cache invalidate, " : "", |
| 3682 | data[1] & (1 << 1) ? "stall at scoreboard, " : |
| 3683 | "", |
| 3684 | data[1] & (1 << 0) ? "depth cache flush, " : |
| 3685 | ""); |
| 3686 | if (len == 5) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3687 | instr_out(ctx, 2, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3688 | "destination address\n"); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3689 | instr_out(ctx, 3, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3690 | "immediate dword low\n"); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3691 | instr_out(ctx, 4, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3692 | "immediate dword high\n"); |
| 3693 | } else { |
| 3694 | for (i = 2; i < len; i++) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3695 | instr_out(ctx, i, "\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3696 | } |
| 3697 | } |
| 3698 | return len; |
| 3699 | } else { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3700 | if (len != 4) |
| 3701 | fprintf(out, "Bad count in PIPE_CONTROL\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3702 | |
| 3703 | switch ((data[0] >> 14) & 0x3) { |
| 3704 | case 0: |
| 3705 | desc1 = "no write"; |
| 3706 | break; |
| 3707 | case 1: |
| 3708 | desc1 = "qword write"; |
| 3709 | break; |
| 3710 | case 2: |
| 3711 | desc1 = "PS_DEPTH_COUNT write"; |
| 3712 | break; |
| 3713 | case 3: |
| 3714 | desc1 = "TIMESTAMP write"; |
| 3715 | break; |
| 3716 | } |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3717 | instr_out(ctx, 0, |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3718 | "PIPE_CONTROL: %s, %sdepth stall, %sRC write flush, " |
| 3719 | "%sinst flush\n", |
| 3720 | desc1, |
| 3721 | data[0] & (1 << 13) ? "" : "no ", |
| 3722 | data[0] & (1 << 12) ? "" : "no ", |
| 3723 | data[0] & (1 << 11) ? "" : "no "); |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3724 | instr_out(ctx, 1, "destination address\n"); |
| 3725 | instr_out(ctx, 2, "immediate dword low\n"); |
| 3726 | instr_out(ctx, 3, "immediate dword high\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3727 | return len; |
| 3728 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3729 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3730 | |
Eric Anholt | b129e10 | 2012-01-04 13:00:29 -0800 | [diff] [blame] | 3731 | if (opcode_3d) { |
Eric Anholt | 3dcb2d4 | 2012-01-04 12:06:44 -0800 | [diff] [blame] | 3732 | if (opcode_3d->func) { |
| 3733 | return opcode_3d->func(ctx); |
| 3734 | } else { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3735 | instr_out(ctx, 0, "%s\n", opcode_3d->name); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3736 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3737 | for (i = 1; i < len; i++) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3738 | instr_out(ctx, i, "dword %d\n", i); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3739 | } |
| 3740 | return len; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3741 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3742 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3743 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3744 | instr_out(ctx, 0, "3D UNKNOWN: 3d_965 opcode = 0x%x\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3745 | opcode); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3746 | return 1; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3747 | } |
| 3748 | |
| 3749 | static int |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3750 | decode_3d_i830(struct drm_intel_decode *ctx) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3751 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3752 | unsigned int idx; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3753 | uint32_t opcode; |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3754 | uint32_t *data = ctx->data; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3755 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3756 | struct { |
| 3757 | uint32_t opcode; |
Eric Anholt | 07768ba | 2011-12-20 13:46:23 -0800 | [diff] [blame] | 3758 | unsigned int min_len; |
| 3759 | unsigned int max_len; |
Eric Anholt | 1db55a8 | 2011-12-20 12:00:28 -0800 | [diff] [blame] | 3760 | const char *name; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3761 | } opcodes_3d[] = { |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 3762 | { 0x02, 1, 1, "3DSTATE_MODES_3" }, |
| 3763 | { 0x03, 1, 1, "3DSTATE_ENABLES_1" }, |
| 3764 | { 0x04, 1, 1, "3DSTATE_ENABLES_2" }, |
| 3765 | { 0x05, 1, 1, "3DSTATE_VFT0" }, |
| 3766 | { 0x06, 1, 1, "3DSTATE_AA" }, |
| 3767 | { 0x07, 1, 1, "3DSTATE_RASTERIZATION_RULES" }, |
| 3768 | { 0x08, 1, 1, "3DSTATE_MODES_1" }, |
| 3769 | { 0x09, 1, 1, "3DSTATE_STENCIL_TEST" }, |
| 3770 | { 0x0a, 1, 1, "3DSTATE_VFT1" }, |
| 3771 | { 0x0b, 1, 1, "3DSTATE_INDPT_ALPHA_BLEND" }, |
| 3772 | { 0x0c, 1, 1, "3DSTATE_MODES_5" }, |
| 3773 | { 0x0d, 1, 1, "3DSTATE_MAP_BLEND_OP" }, |
| 3774 | { 0x0e, 1, 1, "3DSTATE_MAP_BLEND_ARG" }, |
| 3775 | { 0x0f, 1, 1, "3DSTATE_MODES_2" }, |
| 3776 | { 0x15, 1, 1, "3DSTATE_FOG_COLOR" }, |
| 3777 | { 0x16, 1, 1, "3DSTATE_MODES_4"}, |
| 3778 | }, *opcode_3d; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3779 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3780 | opcode = (data[0] & 0x1f000000) >> 24; |
| 3781 | |
| 3782 | switch (opcode) { |
| 3783 | case 0x1f: |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3784 | return decode_3d_primitive(ctx); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3785 | case 0x1d: |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3786 | return decode_3d_1d(ctx); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3787 | case 0x1c: |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3788 | return decode_3d_1c(ctx); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3789 | } |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3790 | |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3791 | for (idx = 0; idx < ARRAY_SIZE(opcodes_3d); idx++) { |
| 3792 | opcode_3d = &opcodes_3d[idx]; |
| 3793 | if ((data[0] & 0x1f000000) >> 24 == opcode_3d->opcode) { |
| 3794 | unsigned int len = 1, i; |
| 3795 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3796 | instr_out(ctx, 0, "%s\n", opcode_3d->name); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3797 | if (opcode_3d->max_len > 1) { |
| 3798 | len = (data[0] & 0xff) + 2; |
| 3799 | if (len < opcode_3d->min_len || |
| 3800 | len > opcode_3d->max_len) { |
| 3801 | fprintf(out, "Bad count in %s\n", |
| 3802 | opcode_3d->name); |
| 3803 | } |
| 3804 | } |
| 3805 | |
| 3806 | for (i = 1; i < len; i++) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3807 | instr_out(ctx, i, "dword %d\n", i); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3808 | } |
| 3809 | return len; |
| 3810 | } |
| 3811 | } |
| 3812 | |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3813 | instr_out(ctx, 0, "3D UNKNOWN: 3d_i830 opcode = 0x%x\n", |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3814 | opcode); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3815 | return 1; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3816 | } |
| 3817 | |
Emil Velikov | 0f8da82 | 2015-03-31 22:32:11 +0100 | [diff] [blame] | 3818 | struct drm_intel_decode * |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3819 | drm_intel_decode_context_alloc(uint32_t devid) |
| 3820 | { |
| 3821 | struct drm_intel_decode *ctx; |
| 3822 | |
| 3823 | ctx = calloc(1, sizeof(struct drm_intel_decode)); |
| 3824 | if (!ctx) |
| 3825 | return NULL; |
| 3826 | |
| 3827 | ctx->devid = devid; |
Eric Anholt | ea33a23 | 2012-01-03 13:05:57 -0800 | [diff] [blame] | 3828 | ctx->out = stdout; |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3829 | |
Ben Widawsky | 5c490bd | 2016-08-24 14:51:43 -0700 | [diff] [blame] | 3830 | if (IS_GEN10(devid)) |
| 3831 | ctx->gen = 10; |
| 3832 | else if (IS_GEN9(devid)) |
Damien Lespiau | 00847fa | 2013-02-13 16:09:38 +0000 | [diff] [blame] | 3833 | ctx->gen = 9; |
| 3834 | else if (IS_GEN8(devid)) |
Damien Lespiau | 946f847 | 2013-02-13 16:09:34 +0000 | [diff] [blame] | 3835 | ctx->gen = 8; |
| 3836 | else if (IS_GEN7(devid)) |
Eric Anholt | 9695eee | 2012-01-04 12:00:59 -0800 | [diff] [blame] | 3837 | ctx->gen = 7; |
| 3838 | else if (IS_GEN6(devid)) |
| 3839 | ctx->gen = 6; |
| 3840 | else if (IS_GEN5(devid)) |
| 3841 | ctx->gen = 5; |
| 3842 | else if (IS_GEN4(devid)) |
| 3843 | ctx->gen = 4; |
| 3844 | else if (IS_9XX(devid)) |
| 3845 | ctx->gen = 3; |
| 3846 | else { |
| 3847 | assert(IS_GEN2(devid)); |
| 3848 | ctx->gen = 2; |
| 3849 | } |
| 3850 | |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3851 | return ctx; |
| 3852 | } |
| 3853 | |
Emil Velikov | 0f8da82 | 2015-03-31 22:32:11 +0100 | [diff] [blame] | 3854 | void |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3855 | drm_intel_decode_context_free(struct drm_intel_decode *ctx) |
| 3856 | { |
| 3857 | free(ctx); |
| 3858 | } |
| 3859 | |
Emil Velikov | 0f8da82 | 2015-03-31 22:32:11 +0100 | [diff] [blame] | 3860 | void |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3861 | drm_intel_decode_set_dump_past_end(struct drm_intel_decode *ctx, |
| 3862 | int dump_past_end) |
| 3863 | { |
| 3864 | ctx->dump_past_end = !!dump_past_end; |
| 3865 | } |
| 3866 | |
Emil Velikov | 0f8da82 | 2015-03-31 22:32:11 +0100 | [diff] [blame] | 3867 | void |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3868 | drm_intel_decode_set_batch_pointer(struct drm_intel_decode *ctx, |
| 3869 | void *data, uint32_t hw_offset, int count) |
| 3870 | { |
Eric Anholt | 8fb66a7 | 2011-12-20 14:59:38 -0800 | [diff] [blame] | 3871 | ctx->base_data = data; |
| 3872 | ctx->base_hw_offset = hw_offset; |
| 3873 | ctx->base_count = count; |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3874 | } |
| 3875 | |
Emil Velikov | 0f8da82 | 2015-03-31 22:32:11 +0100 | [diff] [blame] | 3876 | void |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3877 | drm_intel_decode_set_head_tail(struct drm_intel_decode *ctx, |
| 3878 | uint32_t head, uint32_t tail) |
| 3879 | { |
| 3880 | ctx->head = head; |
| 3881 | ctx->tail = tail; |
| 3882 | } |
| 3883 | |
Emil Velikov | 0f8da82 | 2015-03-31 22:32:11 +0100 | [diff] [blame] | 3884 | void |
Eric Anholt | ea33a23 | 2012-01-03 13:05:57 -0800 | [diff] [blame] | 3885 | drm_intel_decode_set_output_file(struct drm_intel_decode *ctx, |
Emil Velikov | cf7e32b | 2015-08-15 15:42:34 +0100 | [diff] [blame] | 3886 | FILE *output) |
Eric Anholt | ea33a23 | 2012-01-03 13:05:57 -0800 | [diff] [blame] | 3887 | { |
Emil Velikov | cf7e32b | 2015-08-15 15:42:34 +0100 | [diff] [blame] | 3888 | ctx->out = output; |
Eric Anholt | ea33a23 | 2012-01-03 13:05:57 -0800 | [diff] [blame] | 3889 | } |
| 3890 | |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3891 | /** |
| 3892 | * Decodes an i830-i915 batch buffer, writing the output to stdout. |
| 3893 | * |
| 3894 | * \param data batch buffer contents |
| 3895 | * \param count number of DWORDs to decode in the batch buffer |
| 3896 | * \param hw_offset hardware address for the buffer |
| 3897 | */ |
Emil Velikov | 0f8da82 | 2015-03-31 22:32:11 +0100 | [diff] [blame] | 3898 | void |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3899 | drm_intel_decode(struct drm_intel_decode *ctx) |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3900 | { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3901 | int ret; |
Eric Anholt | 07768ba | 2011-12-20 13:46:23 -0800 | [diff] [blame] | 3902 | unsigned int index = 0; |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3903 | uint32_t devid; |
Thomas Hindoe Paaboel Andersen | 5ee9cb4 | 2017-02-02 23:57:29 +0100 | [diff] [blame] | 3904 | int size; |
Eric Anholt | 028715e | 2012-01-04 12:31:40 -0800 | [diff] [blame] | 3905 | void *temp; |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3906 | |
| 3907 | if (!ctx) |
| 3908 | return; |
| 3909 | |
Eric Anholt | 028715e | 2012-01-04 12:31:40 -0800 | [diff] [blame] | 3910 | /* Put a scratch page full of obviously undefined data after |
| 3911 | * the batchbuffer. This lets us avoid a bunch of length |
| 3912 | * checking in statically sized packets. |
| 3913 | */ |
Thomas Hindoe Paaboel Andersen | 5ee9cb4 | 2017-02-02 23:57:29 +0100 | [diff] [blame] | 3914 | size = ctx->base_count * 4; |
Eric Anholt | 028715e | 2012-01-04 12:31:40 -0800 | [diff] [blame] | 3915 | temp = malloc(size + 4096); |
| 3916 | memcpy(temp, ctx->base_data, size); |
| 3917 | memset((char *)temp + size, 0xd0, 4096); |
| 3918 | ctx->data = temp; |
| 3919 | |
Eric Anholt | 8fb66a7 | 2011-12-20 14:59:38 -0800 | [diff] [blame] | 3920 | ctx->hw_offset = ctx->base_hw_offset; |
| 3921 | ctx->count = ctx->base_count; |
| 3922 | |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3923 | devid = ctx->devid; |
| 3924 | head_offset = ctx->head; |
| 3925 | tail_offset = ctx->tail; |
Eric Anholt | ea33a23 | 2012-01-03 13:05:57 -0800 | [diff] [blame] | 3926 | out = ctx->out; |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3927 | |
| 3928 | saved_s2_set = 0; |
| 3929 | saved_s4_set = 1; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3930 | |
Eric Anholt | 8fb66a7 | 2011-12-20 14:59:38 -0800 | [diff] [blame] | 3931 | while (ctx->count > 0) { |
| 3932 | index = 0; |
| 3933 | |
| 3934 | switch ((ctx->data[index] & 0xe0000000) >> 29) { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3935 | case 0x0: |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3936 | ret = decode_mi(ctx); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3937 | |
Eric Anholt | bbdda92 | 2011-12-20 11:44:36 -0800 | [diff] [blame] | 3938 | /* If MI_BATCHBUFFER_END happened, then dump |
| 3939 | * the rest of the output in case we some day |
| 3940 | * want it in debugging, but don't decode it |
| 3941 | * since it'll just confuse in the common |
| 3942 | * case. |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3943 | */ |
| 3944 | if (ret == -1) { |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3945 | if (ctx->dump_past_end) { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3946 | index++; |
| 3947 | } else { |
Eric Anholt | 8fb66a7 | 2011-12-20 14:59:38 -0800 | [diff] [blame] | 3948 | for (index = index + 1; index < ctx->count; |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3949 | index++) { |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3950 | instr_out(ctx, index, "\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3951 | } |
| 3952 | } |
| 3953 | } else |
| 3954 | index += ret; |
| 3955 | break; |
| 3956 | case 0x2: |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3957 | index += decode_2d(ctx); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3958 | break; |
| 3959 | case 0x3: |
Eric Anholt | 71066ab | 2011-12-20 13:06:16 -0800 | [diff] [blame] | 3960 | if (IS_9XX(devid) && !IS_GEN3(devid)) { |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3961 | index += |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3962 | decode_3d_965(ctx); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3963 | } else if (IS_GEN3(devid)) { |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3964 | index += decode_3d(ctx); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3965 | } else { |
| 3966 | index += |
Eric Anholt | de49fd4 | 2011-12-20 15:15:21 -0800 | [diff] [blame] | 3967 | decode_3d_i830(ctx); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3968 | } |
| 3969 | break; |
| 3970 | default: |
Eric Anholt | c1d2946 | 2011-12-20 15:29:03 -0800 | [diff] [blame] | 3971 | instr_out(ctx, index, "UNKNOWN\n"); |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3972 | index++; |
| 3973 | break; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3974 | } |
Eric Anholt | 193fa13 | 2011-12-20 11:36:07 -0800 | [diff] [blame] | 3975 | fflush(out); |
Eric Anholt | 8fb66a7 | 2011-12-20 14:59:38 -0800 | [diff] [blame] | 3976 | |
| 3977 | if (ctx->count < index) |
| 3978 | break; |
| 3979 | |
| 3980 | ctx->count -= index; |
| 3981 | ctx->data += index; |
| 3982 | ctx->hw_offset += 4 * index; |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3983 | } |
Eric Anholt | 028715e | 2012-01-04 12:31:40 -0800 | [diff] [blame] | 3984 | |
| 3985 | free(temp); |
Eric Anholt | 8c4a2c8 | 2011-12-20 11:25:20 -0800 | [diff] [blame] | 3986 | } |