Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017-2019 Alyssa Rosenzweig |
| 3 | * Copyright (C) 2017-2019 Connor Abbott |
Alyssa Rosenzweig | d4575c3 | 2019-06-25 13:30:17 -0700 | [diff] [blame] | 4 | * Copyright (C) 2019 Collabora, Ltd. |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice (including the next |
| 14 | * paragraph) shall be included in all copies or substantial portions of the |
| 15 | * Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 23 | * SOFTWARE. |
| 24 | */ |
| 25 | |
Alyssa Rosenzweig | 88dc4c2 | 2020-08-05 18:13:11 -0400 | [diff] [blame] | 26 | #include <midgard_pack.h> |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 27 | #include <stdio.h> |
| 28 | #include <stdlib.h> |
| 29 | #include <memory.h> |
| 30 | #include <stdbool.h> |
| 31 | #include <stdarg.h> |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 32 | #include <ctype.h> |
Alyssa Rosenzweig | fc7bcee | 2019-06-11 12:25:35 -0700 | [diff] [blame] | 33 | #include "decode.h" |
Lionel Landwerlin | 6637395 | 2019-08-09 16:39:58 +0300 | [diff] [blame] | 34 | #include "util/macros.h" |
Alyssa Rosenzweig | d699ffb | 2019-05-14 22:21:39 +0000 | [diff] [blame] | 35 | #include "util/u_math.h" |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 36 | |
Alyssa Rosenzweig | ec2a59c | 2019-07-10 10:33:24 -0700 | [diff] [blame] | 37 | #include "midgard/disassemble.h" |
| 38 | #include "bifrost/disassemble.h" |
| 39 | |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 40 | #include "pan_encoder.h" |
| 41 | |
Tomeu Vizoso | 9447a84 | 2019-10-30 12:05:30 +0100 | [diff] [blame] | 42 | static void pandecode_swizzle(unsigned swizzle, enum mali_format format); |
| 43 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 44 | #define MEMORY_PROP(obj, p) {\ |
Alyssa Rosenzweig | 2608da1 | 2019-06-19 09:35:57 -0700 | [diff] [blame] | 45 | if (obj->p) { \ |
| 46 | char *a = pointer_as_memory_reference(obj->p); \ |
| 47 | pandecode_prop("%s = %s", #p, a); \ |
| 48 | free(a); \ |
| 49 | } \ |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 50 | } |
| 51 | |
Alyssa Rosenzweig | 0c1874a | 2019-07-12 08:47:35 -0700 | [diff] [blame] | 52 | #define MEMORY_PROP_DIR(obj, p) {\ |
| 53 | if (obj.p) { \ |
| 54 | char *a = pointer_as_memory_reference(obj.p); \ |
| 55 | pandecode_prop("%s = %s", #p, a); \ |
| 56 | free(a); \ |
| 57 | } \ |
| 58 | } |
| 59 | |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 60 | #define DUMP_UNPACKED(T, var, ...) { \ |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 61 | pandecode_log(__VA_ARGS__); \ |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 62 | pan_print(pandecode_dump_stream, T, var, (pandecode_indent + 1) * 2); \ |
| 63 | } |
| 64 | |
| 65 | #define DUMP_CL(T, cl, ...) {\ |
Boris Brezillon | 62c0ef0 | 2020-09-05 18:04:43 +0200 | [diff] [blame] | 66 | pan_unpack(cl, T, temp); \ |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 67 | DUMP_UNPACKED(T, temp, __VA_ARGS__); \ |
Alyssa Rosenzweig | d2ddd4d | 2020-08-05 19:43:58 -0400 | [diff] [blame] | 68 | } |
| 69 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 70 | #define DUMP_SECTION(A, S, cl, ...) { \ |
| 71 | pan_section_unpack(cl, A, S, temp); \ |
| 72 | pandecode_log(__VA_ARGS__); \ |
| 73 | pan_section_print(pandecode_dump_stream, A, S, temp, (pandecode_indent + 1) * 2); \ |
| 74 | } |
| 75 | |
Alyssa Rosenzweig | 4e3fe54 | 2020-08-14 16:03:12 -0400 | [diff] [blame] | 76 | #define MAP_ADDR(T, addr, cl) \ |
| 77 | const uint8_t *cl = 0; \ |
| 78 | { \ |
| 79 | struct pandecode_mapped_memory *mapped_mem = pandecode_find_mapped_gpu_mem_containing(addr); \ |
| 80 | cl = pandecode_fetch_gpu_mem(mapped_mem, addr, MALI_ ## T ## _LENGTH); \ |
| 81 | } |
| 82 | |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 83 | #define DUMP_ADDR(T, addr, ...) {\ |
Alyssa Rosenzweig | 4e3fe54 | 2020-08-14 16:03:12 -0400 | [diff] [blame] | 84 | MAP_ADDR(T, addr, cl) \ |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 85 | DUMP_CL(T, cl, __VA_ARGS__); \ |
Alyssa Rosenzweig | d2ddd4d | 2020-08-05 19:43:58 -0400 | [diff] [blame] | 86 | } |
| 87 | |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 88 | FILE *pandecode_dump_stream; |
| 89 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 90 | /* Semantic logging type. |
| 91 | * |
| 92 | * Raw: for raw messages to be printed as is. |
| 93 | * Message: for helpful information to be commented out in replays. |
| 94 | * Property: for properties of a struct |
| 95 | * |
| 96 | * Use one of pandecode_log, pandecode_msg, or pandecode_prop as syntax sugar. |
| 97 | */ |
| 98 | |
| 99 | enum pandecode_log_type { |
| 100 | PANDECODE_RAW, |
| 101 | PANDECODE_MESSAGE, |
| 102 | PANDECODE_PROPERTY |
| 103 | }; |
| 104 | |
| 105 | #define pandecode_log(...) pandecode_log_typed(PANDECODE_RAW, __VA_ARGS__) |
| 106 | #define pandecode_msg(...) pandecode_log_typed(PANDECODE_MESSAGE, __VA_ARGS__) |
| 107 | #define pandecode_prop(...) pandecode_log_typed(PANDECODE_PROPERTY, __VA_ARGS__) |
| 108 | |
| 109 | unsigned pandecode_indent = 0; |
| 110 | |
| 111 | static void |
| 112 | pandecode_make_indent(void) |
| 113 | { |
| 114 | for (unsigned i = 0; i < pandecode_indent; ++i) |
Boris Brezillon | 6249ae7 | 2020-09-09 17:52:23 +0200 | [diff] [blame] | 115 | fprintf(pandecode_dump_stream, " "); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | static void |
| 119 | pandecode_log_typed(enum pandecode_log_type type, const char *format, ...) |
| 120 | { |
| 121 | va_list ap; |
| 122 | |
| 123 | pandecode_make_indent(); |
| 124 | |
| 125 | if (type == PANDECODE_MESSAGE) |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 126 | fprintf(pandecode_dump_stream, "// "); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 127 | else if (type == PANDECODE_PROPERTY) |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 128 | fprintf(pandecode_dump_stream, "."); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 129 | |
| 130 | va_start(ap, format); |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 131 | vfprintf(pandecode_dump_stream, format, ap); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 132 | va_end(ap); |
| 133 | |
| 134 | if (type == PANDECODE_PROPERTY) |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 135 | fprintf(pandecode_dump_stream, ",\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | static void |
| 139 | pandecode_log_cont(const char *format, ...) |
| 140 | { |
| 141 | va_list ap; |
| 142 | |
| 143 | va_start(ap, format); |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 144 | vfprintf(pandecode_dump_stream, format, ap); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 145 | va_end(ap); |
| 146 | } |
| 147 | |
Alyssa Rosenzweig | 4391c65 | 2019-08-19 15:14:48 -0700 | [diff] [blame] | 148 | /* To check for memory safety issues, validates that the given pointer in GPU |
| 149 | * memory is valid, containing at least sz bytes. The goal is to eliminate |
| 150 | * GPU-side memory bugs (NULL pointer dereferences, buffer overflows, or buffer |
| 151 | * overruns) by statically validating pointers. |
| 152 | */ |
| 153 | |
| 154 | static void |
| 155 | pandecode_validate_buffer(mali_ptr addr, size_t sz) |
| 156 | { |
| 157 | if (!addr) { |
| 158 | pandecode_msg("XXX: null pointer deref"); |
| 159 | return; |
| 160 | } |
| 161 | |
| 162 | /* Find a BO */ |
| 163 | |
| 164 | struct pandecode_mapped_memory *bo = |
| 165 | pandecode_find_mapped_gpu_mem_containing(addr); |
| 166 | |
| 167 | if (!bo) { |
| 168 | pandecode_msg("XXX: invalid memory dereference\n"); |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | /* Bounds check */ |
| 173 | |
| 174 | unsigned offset = addr - bo->gpu_va; |
| 175 | unsigned total = offset + sz; |
| 176 | |
| 177 | if (total > bo->length) { |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 178 | pandecode_msg("XXX: buffer overrun. " |
Alyssa Rosenzweig | bcfcb7e | 2019-08-30 17:02:43 -0700 | [diff] [blame] | 179 | "Chunk of size %zu at offset %d in buffer of size %zu. " |
| 180 | "Overrun by %zu bytes. \n", |
Alyssa Rosenzweig | 4391c65 | 2019-08-19 15:14:48 -0700 | [diff] [blame] | 181 | sz, offset, bo->length, total - bo->length); |
| 182 | return; |
| 183 | } |
| 184 | } |
| 185 | |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 186 | /* Midgard's tiler descriptor is embedded within the |
| 187 | * larger FBD */ |
| 188 | |
| 189 | static void |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 190 | pandecode_midgard_tiler_descriptor( |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 191 | const struct mali_midgard_tiler_packed *tp, |
| 192 | const struct mali_midgard_tiler_weights_packed *wp, |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 193 | unsigned width, |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 194 | unsigned height, |
Alyssa Rosenzweig | 9fb0904 | 2019-11-27 08:31:16 -0500 | [diff] [blame] | 195 | bool is_fragment, |
| 196 | bool has_hierarchy) |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 197 | { |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 198 | pan_unpack(tp, MIDGARD_TILER, t); |
| 199 | DUMP_UNPACKED(MIDGARD_TILER, t, "Tiler:\n"); |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 200 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 201 | MEMORY_PROP_DIR(t, polygon_list); |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 202 | |
Alyssa Rosenzweig | 52101e4 | 2019-08-19 10:38:25 -0700 | [diff] [blame] | 203 | /* The body is offset from the base of the polygon list */ |
Alyssa Rosenzweig | b010a6d | 2020-04-06 20:31:32 -0400 | [diff] [blame] | 204 | //assert(t->polygon_list_body > t->polygon_list); |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 205 | unsigned body_offset = t.polygon_list_body - t.polygon_list; |
Alyssa Rosenzweig | 52101e4 | 2019-08-19 10:38:25 -0700 | [diff] [blame] | 206 | |
| 207 | /* It needs to fit inside the reported size */ |
Alyssa Rosenzweig | b010a6d | 2020-04-06 20:31:32 -0400 | [diff] [blame] | 208 | //assert(t->polygon_list_size >= body_offset); |
Alyssa Rosenzweig | 52101e4 | 2019-08-19 10:38:25 -0700 | [diff] [blame] | 209 | |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 210 | /* Now that we've sanity checked, we'll try to calculate the sizes |
| 211 | * ourselves for comparison */ |
| 212 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 213 | unsigned ref_header = panfrost_tiler_header_size(width, height, t.hierarchy_mask, has_hierarchy); |
| 214 | unsigned ref_size = panfrost_tiler_full_size(width, height, t.hierarchy_mask, has_hierarchy); |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 215 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 216 | if (!((ref_header == body_offset) && (ref_size == t.polygon_list_size))) { |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 217 | pandecode_msg("XXX: bad polygon list size (expected %d / 0x%x)\n", |
| 218 | ref_header, ref_size); |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 219 | pandecode_prop("polygon_list_size = 0x%x", t.polygon_list_size); |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 220 | pandecode_msg("body offset %d\n", body_offset); |
| 221 | } |
Alyssa Rosenzweig | 52101e4 | 2019-08-19 10:38:25 -0700 | [diff] [blame] | 222 | |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 223 | /* The tiler heap has a start and end specified -- it should be |
| 224 | * identical to what we have in the BO. The exception is if tiling is |
| 225 | * disabled. */ |
Alyssa Rosenzweig | 13d0797 | 2019-08-19 10:56:23 -0700 | [diff] [blame] | 226 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 227 | MEMORY_PROP_DIR(t, heap_start); |
| 228 | assert(t.heap_end >= t.heap_start); |
Alyssa Rosenzweig | 13d0797 | 2019-08-19 10:56:23 -0700 | [diff] [blame] | 229 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 230 | unsigned heap_size = t.heap_end - t.heap_start; |
Alyssa Rosenzweig | 13d0797 | 2019-08-19 10:56:23 -0700 | [diff] [blame] | 231 | |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 232 | /* Tiling is enabled with a special flag */ |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 233 | unsigned hierarchy_mask = t.hierarchy_mask & MALI_MIDGARD_TILER_HIERARCHY_MASK; |
| 234 | unsigned tiler_flags = t.hierarchy_mask ^ hierarchy_mask; |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 235 | |
| 236 | bool tiling_enabled = hierarchy_mask; |
| 237 | |
| 238 | if (tiling_enabled) { |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 239 | /* We should also have no other flags */ |
| 240 | if (tiler_flags) |
| 241 | pandecode_msg("XXX: unexpected tiler %X\n", tiler_flags); |
| 242 | } else { |
| 243 | /* When tiling is disabled, we should have that flag and no others */ |
| 244 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 245 | if (tiler_flags != MALI_MIDGARD_TILER_DISABLED) { |
| 246 | pandecode_msg("XXX: unexpected tiler flag %X, expected MALI_MIDGARD_TILER_DISABLED\n", |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 247 | tiler_flags); |
| 248 | } |
| 249 | |
| 250 | /* We should also have an empty heap */ |
| 251 | if (heap_size) { |
| 252 | pandecode_msg("XXX: tiler heap size %d given, expected empty\n", |
| 253 | heap_size); |
| 254 | } |
| 255 | |
| 256 | /* Disabled tiling is used only for clear-only jobs, which are |
| 257 | * purely FRAGMENT, so we should never see this for |
| 258 | * non-FRAGMENT descriptors. */ |
| 259 | |
| 260 | if (!is_fragment) |
| 261 | pandecode_msg("XXX: tiler disabled for non-FRAGMENT job\n"); |
| 262 | } |
| 263 | |
| 264 | /* We've never seen weights used in practice, but we know from the |
| 265 | * kernel these fields is there */ |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 266 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 267 | pan_unpack(wp, MIDGARD_TILER_WEIGHTS, w); |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 268 | bool nonzero_weights = false; |
| 269 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 270 | nonzero_weights |= w.weight0 != 0x0; |
| 271 | nonzero_weights |= w.weight1 != 0x0; |
| 272 | nonzero_weights |= w.weight2 != 0x0; |
| 273 | nonzero_weights |= w.weight3 != 0x0; |
| 274 | nonzero_weights |= w.weight4 != 0x0; |
| 275 | nonzero_weights |= w.weight5 != 0x0; |
| 276 | nonzero_weights |= w.weight6 != 0x0; |
| 277 | nonzero_weights |= w.weight7 != 0x0; |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 278 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 279 | if (nonzero_weights) |
| 280 | DUMP_UNPACKED(MIDGARD_TILER_WEIGHTS, w, "Tiler Weights:\n"); |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 281 | } |
| 282 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 283 | /* Information about the framebuffer passed back for |
| 284 | * additional analysis */ |
| 285 | |
| 286 | struct pandecode_fbd { |
| 287 | unsigned width; |
| 288 | unsigned height; |
| 289 | unsigned rt_count; |
| 290 | bool has_extra; |
| 291 | }; |
| 292 | |
| 293 | static struct pandecode_fbd |
Tomeu Vizoso | 697f02c | 2019-11-12 12:15:02 +0100 | [diff] [blame] | 294 | pandecode_sfbd(uint64_t gpu_va, int job_no, bool is_fragment, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 295 | { |
| 296 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 297 | const void *PANDECODE_PTR_VAR(s, mem, (mali_ptr) gpu_va); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 298 | |
Alyssa Rosenzweig | d6d6d63 | 2019-08-30 17:00:09 -0700 | [diff] [blame] | 299 | struct pandecode_fbd info = { |
| 300 | .has_extra = false, |
| 301 | .rt_count = 1 |
| 302 | }; |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 303 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 304 | pandecode_log("Single-Target Framebuffer:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 305 | pandecode_indent++; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 306 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 307 | DUMP_SECTION(SINGLE_TARGET_FRAMEBUFFER, LOCAL_STORAGE, s, "Local Storage:\n"); |
| 308 | pan_section_unpack(s, SINGLE_TARGET_FRAMEBUFFER, PARAMETERS, p); |
| 309 | DUMP_UNPACKED(SINGLE_TARGET_FRAMEBUFFER_PARAMETERS, p, "Parameters:\n"); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 310 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 311 | const void *t = pan_section_ptr(s, SINGLE_TARGET_FRAMEBUFFER, TILER); |
| 312 | const void *w = pan_section_ptr(s, SINGLE_TARGET_FRAMEBUFFER, TILER_WEIGHTS); |
Alyssa Rosenzweig | 9fb0904 | 2019-11-27 08:31:16 -0500 | [diff] [blame] | 313 | |
| 314 | bool has_hierarchy = !(gpu_id == 0x0720 || gpu_id == 0x0820 || gpu_id == 0x0830); |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 315 | pandecode_midgard_tiler_descriptor(t, w, p.bound_max_x + 1, p.bound_max_y + 1, is_fragment, has_hierarchy); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 316 | |
| 317 | pandecode_indent--; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 318 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 319 | /* Dummy unpack of the padding section to make sure all words are 0. |
| 320 | * No need to call print here since the section is supposed to be empty. |
| 321 | */ |
| 322 | pan_section_unpack(s, SINGLE_TARGET_FRAMEBUFFER, PADDING_1, padding1); |
| 323 | pan_section_unpack(s, SINGLE_TARGET_FRAMEBUFFER, PADDING_2, padding2); |
| 324 | pandecode_log("\n"); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 325 | |
| 326 | return info; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | static void |
Alyssa Rosenzweig | 0aa5d89 | 2019-06-19 08:41:51 -0700 | [diff] [blame] | 330 | pandecode_compute_fbd(uint64_t gpu_va, int job_no) |
| 331 | { |
| 332 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); |
Boris Brezillon | 3a06fc3 | 2020-09-03 09:18:09 +0200 | [diff] [blame] | 333 | const struct mali_local_storage_packed *PANDECODE_PTR_VAR(s, mem, (mali_ptr) gpu_va); |
| 334 | DUMP_CL(LOCAL_STORAGE, s, "Local Storage:\n"); |
Alyssa Rosenzweig | 0aa5d89 | 2019-06-19 08:41:51 -0700 | [diff] [blame] | 335 | } |
| 336 | |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 337 | /* Extracts the number of components associated with a Mali format */ |
| 338 | |
| 339 | static unsigned |
| 340 | pandecode_format_component_count(enum mali_format fmt) |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 341 | { |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 342 | /* Mask out the format class */ |
| 343 | unsigned top = fmt & 0b11100000; |
| 344 | |
| 345 | switch (top) { |
| 346 | case MALI_FORMAT_SNORM: |
| 347 | case MALI_FORMAT_UINT: |
| 348 | case MALI_FORMAT_UNORM: |
| 349 | case MALI_FORMAT_SINT: |
| 350 | return ((fmt >> 3) & 3) + 1; |
| 351 | default: |
| 352 | /* TODO: Validate */ |
| 353 | return 4; |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | /* Extracts a mask of accessed components from a 12-bit Mali swizzle */ |
| 358 | |
| 359 | static unsigned |
| 360 | pandecode_access_mask_from_channel_swizzle(unsigned swizzle) |
| 361 | { |
| 362 | unsigned mask = 0; |
Alyssa Rosenzweig | cdc3276 | 2020-08-12 16:46:07 -0400 | [diff] [blame] | 363 | assert(MALI_CHANNEL_R == 0); |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 364 | |
| 365 | for (unsigned c = 0; c < 4; ++c) { |
| 366 | enum mali_channel chan = (swizzle >> (3*c)) & 0x7; |
| 367 | |
Alyssa Rosenzweig | cdc3276 | 2020-08-12 16:46:07 -0400 | [diff] [blame] | 368 | if (chan <= MALI_CHANNEL_A) |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 369 | mask |= (1 << chan); |
| 370 | } |
| 371 | |
| 372 | return mask; |
| 373 | } |
| 374 | |
| 375 | /* Validates that a (format, swizzle) pair is valid, in the sense that the |
| 376 | * swizzle doesn't access any components that are undefined in the format. |
| 377 | * Returns whether the swizzle is trivial (doesn't do any swizzling) and can be |
| 378 | * omitted */ |
| 379 | |
| 380 | static bool |
| 381 | pandecode_validate_format_swizzle(enum mali_format fmt, unsigned swizzle) |
| 382 | { |
| 383 | unsigned nr_comp = pandecode_format_component_count(fmt); |
| 384 | unsigned access_mask = pandecode_access_mask_from_channel_swizzle(swizzle); |
| 385 | unsigned valid_mask = (1 << nr_comp) - 1; |
| 386 | unsigned invalid_mask = ~valid_mask; |
| 387 | |
| 388 | if (access_mask & invalid_mask) { |
| 389 | pandecode_msg("XXX: invalid components accessed\n"); |
| 390 | return false; |
| 391 | } |
| 392 | |
| 393 | /* Check for the default non-swizzling swizzle so we can suppress |
| 394 | * useless printing for the defaults */ |
| 395 | |
| 396 | unsigned default_swizzles[4] = { |
Alyssa Rosenzweig | cdc3276 | 2020-08-12 16:46:07 -0400 | [diff] [blame] | 397 | MALI_CHANNEL_R | (MALI_CHANNEL_0 << 3) | (MALI_CHANNEL_0 << 6) | (MALI_CHANNEL_1 << 9), |
| 398 | MALI_CHANNEL_R | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_0 << 6) | (MALI_CHANNEL_1 << 9), |
| 399 | MALI_CHANNEL_R | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_B << 6) | (MALI_CHANNEL_1 << 9), |
| 400 | MALI_CHANNEL_R | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_B << 6) | (MALI_CHANNEL_A << 9) |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 401 | }; |
| 402 | |
| 403 | return (swizzle == default_swizzles[nr_comp - 1]); |
| 404 | } |
| 405 | |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 406 | static void |
| 407 | pandecode_swizzle(unsigned swizzle, enum mali_format format) |
| 408 | { |
| 409 | /* First, do some validation */ |
| 410 | bool trivial_swizzle = pandecode_validate_format_swizzle( |
| 411 | format, swizzle); |
| 412 | |
| 413 | if (trivial_swizzle) |
| 414 | return; |
| 415 | |
| 416 | /* Next, print the swizzle */ |
| 417 | pandecode_log_cont("."); |
| 418 | |
| 419 | static const char components[] = "rgba01"; |
| 420 | |
| 421 | for (unsigned c = 0; c < 4; ++c) { |
| 422 | enum mali_channel chan = (swizzle >> (3 * c)) & 0x7; |
| 423 | |
Alyssa Rosenzweig | cdc3276 | 2020-08-12 16:46:07 -0400 | [diff] [blame] | 424 | if (chan > MALI_CHANNEL_1) { |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 425 | pandecode_log("XXX: invalid swizzle channel %d\n", chan); |
| 426 | continue; |
| 427 | } |
| 428 | pandecode_log_cont("%c", components[chan]); |
| 429 | } |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 430 | } |
| 431 | |
| 432 | static void |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 433 | pandecode_render_target(uint64_t gpu_va, unsigned job_no, bool is_bifrost, unsigned gpu_id, |
| 434 | const struct MALI_MULTI_TARGET_FRAMEBUFFER_PARAMETERS *fb) |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 435 | { |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 436 | pandecode_log("Color Render Targets:\n"); |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 437 | pandecode_indent++; |
| 438 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 439 | for (int i = 0; i < (fb->render_target_count); i++) { |
| 440 | mali_ptr rt_va = gpu_va + i * MALI_RENDER_TARGET_LENGTH; |
| 441 | struct pandecode_mapped_memory *mem = |
| 442 | pandecode_find_mapped_gpu_mem_containing(rt_va); |
| 443 | const struct mali_render_target_packed *PANDECODE_PTR_VAR(rtp, mem, (mali_ptr) rt_va); |
| 444 | DUMP_CL(RENDER_TARGET, rtp, "Color Render Target %d:\n", i); |
Alyssa Rosenzweig | e49204c | 2019-08-20 11:11:46 -0700 | [diff] [blame] | 445 | } |
Alyssa Rosenzweig | b78e04c | 2019-08-14 16:01:38 -0700 | [diff] [blame] | 446 | |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 447 | pandecode_indent--; |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 448 | pandecode_log("\n"); |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 449 | } |
| 450 | |
| 451 | static void |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 452 | pandecode_mfbd_bifrost_deps(const void *fb, int job_no) |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 453 | { |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 454 | pan_section_unpack(fb, MULTI_TARGET_FRAMEBUFFER, BIFROST_PARAMETERS, params); |
| 455 | |
| 456 | /* The blob stores all possible sample locations in a single buffer |
| 457 | * allocated on startup, and just switches the pointer when switching |
| 458 | * MSAA state. For now, we just put the data into the cmdstream, but we |
| 459 | * should do something like what the blob does with a real driver. |
| 460 | * |
| 461 | * There seem to be 32 slots for sample locations, followed by another |
| 462 | * 16. The second 16 is just the center location followed by 15 zeros |
| 463 | * in all the cases I've identified (maybe shader vs. depth/color |
| 464 | * samples?). |
| 465 | */ |
| 466 | |
| 467 | struct pandecode_mapped_memory *smem = |
| 468 | pandecode_find_mapped_gpu_mem_containing(params.sample_locations); |
| 469 | |
| 470 | const u16 *PANDECODE_PTR_VAR(samples, smem, params.sample_locations); |
| 471 | |
| 472 | pandecode_log("uint16_t sample_locations_%d[] = {\n", job_no); |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 473 | pandecode_indent++; |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 474 | for (int i = 0; i < 32 + 16; i++) { |
| 475 | pandecode_log("%d, %d,\n", samples[2 * i], samples[2 * i + 1]); |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | pandecode_indent--; |
| 479 | pandecode_log("};\n"); |
| 480 | } |
| 481 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 482 | static struct pandecode_fbd |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 483 | pandecode_mfbd_bfr(uint64_t gpu_va, int job_no, bool is_fragment, bool is_compute, bool is_bifrost, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 484 | { |
| 485 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 486 | const void *PANDECODE_PTR_VAR(fb, mem, (mali_ptr) gpu_va); |
| 487 | pan_section_unpack(fb, MULTI_TARGET_FRAMEBUFFER, PARAMETERS, params); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 488 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 489 | struct pandecode_fbd info; |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 490 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 491 | if (is_bifrost) |
| 492 | pandecode_mfbd_bifrost_deps(fb, job_no); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 493 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 494 | pandecode_log("Multi-Target Framebuffer:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 495 | pandecode_indent++; |
| 496 | |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 497 | if (is_bifrost) { |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 498 | DUMP_SECTION(MULTI_TARGET_FRAMEBUFFER, BIFROST_PARAMETERS, fb, "Bifrost Params:\n"); |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 499 | } else { |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 500 | DUMP_SECTION(MULTI_TARGET_FRAMEBUFFER, LOCAL_STORAGE, fb, "Local Storage:\n"); |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 501 | } |
Alyssa Rosenzweig | 85e745f | 2019-06-12 09:33:06 -0700 | [diff] [blame] | 502 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 503 | info.width = params.width; |
| 504 | info.height = params.height; |
| 505 | info.rt_count = params.render_target_count; |
| 506 | DUMP_UNPACKED(MULTI_TARGET_FRAMEBUFFER_PARAMETERS, params, "Parameters:\n"); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 507 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 508 | if (!is_compute) { |
| 509 | if (is_bifrost) { |
| 510 | DUMP_SECTION(MULTI_TARGET_FRAMEBUFFER, BIFROST_TILER_POINTER, fb, "Tiler Pointer"); |
| 511 | } else { |
| 512 | const void *t = pan_section_ptr(fb, MULTI_TARGET_FRAMEBUFFER, TILER); |
| 513 | const void *w = pan_section_ptr(fb, MULTI_TARGET_FRAMEBUFFER, TILER_WEIGHTS); |
| 514 | pandecode_midgard_tiler_descriptor(t, w, params.width, params.height, is_fragment, true); |
Alyssa Rosenzweig | c2c8b1a | 2020-05-26 18:10:39 -0400 | [diff] [blame] | 515 | } |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 516 | } else { |
Alyssa Rosenzweig | 3993969 | 2020-01-22 08:51:19 -0500 | [diff] [blame] | 517 | pandecode_msg("XXX: skipping compute MFBD, fixme\n"); |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 518 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 519 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 520 | if (is_bifrost) { |
| 521 | pan_section_unpack(fb, MULTI_TARGET_FRAMEBUFFER, BIFROST_PADDING, padding); |
Alyssa Rosenzweig | 85e745f | 2019-06-12 09:33:06 -0700 | [diff] [blame] | 522 | } |
| 523 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 524 | pandecode_indent--; |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 525 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 526 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 527 | gpu_va += MALI_MULTI_TARGET_FRAMEBUFFER_LENGTH; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 528 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 529 | info.has_extra = params.has_zs_crc_extension; |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 530 | |
| 531 | if (info.has_extra) { |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 532 | struct pandecode_mapped_memory *mem = |
| 533 | pandecode_find_mapped_gpu_mem_containing(gpu_va); |
| 534 | const struct mali_zs_crc_extension_packed *PANDECODE_PTR_VAR(zs_crc, mem, (mali_ptr)gpu_va); |
| 535 | DUMP_CL(ZS_CRC_EXTENSION, zs_crc, "ZS CRC Extension:\n"); |
| 536 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 537 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 538 | gpu_va += MALI_ZS_CRC_EXTENSION_LENGTH; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 539 | } |
| 540 | |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 541 | if (is_fragment) |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 542 | pandecode_render_target(gpu_va, job_no, is_bifrost, gpu_id, ¶ms); |
Alyssa Rosenzweig | a9fc1c8 | 2019-06-23 11:29:46 -0700 | [diff] [blame] | 543 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 544 | return info; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 545 | } |
| 546 | |
| 547 | static void |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 548 | pandecode_attributes(const struct pandecode_mapped_memory *mem, |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 549 | mali_ptr addr, int job_no, char *suffix, |
Alyssa Rosenzweig | f4678f3 | 2019-08-22 13:27:38 -0700 | [diff] [blame] | 550 | int count, bool varying, enum mali_job_type job_type) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 551 | { |
Alyssa Rosenzweig | 4e3fe54 | 2020-08-14 16:03:12 -0400 | [diff] [blame] | 552 | char *prefix = varying ? "Varying" : "Attribute"; |
Alyssa Rosenzweig | ed464e0 | 2019-08-22 13:07:01 -0700 | [diff] [blame] | 553 | assert(addr); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 554 | |
Alyssa Rosenzweig | ed464e0 | 2019-08-22 13:07:01 -0700 | [diff] [blame] | 555 | if (!count) { |
| 556 | pandecode_msg("warn: No %s records\n", prefix); |
Alyssa Rosenzweig | 5ad8301 | 2019-08-08 09:23:29 -0700 | [diff] [blame] | 557 | return; |
| 558 | } |
| 559 | |
Alyssa Rosenzweig | 4e3fe54 | 2020-08-14 16:03:12 -0400 | [diff] [blame] | 560 | MAP_ADDR(ATTRIBUTE_BUFFER, addr, cl); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 561 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 562 | for (int i = 0; i < count; ++i) { |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 563 | pan_unpack(cl + i * MALI_ATTRIBUTE_BUFFER_LENGTH, ATTRIBUTE_BUFFER, temp); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 564 | DUMP_UNPACKED(ATTRIBUTE_BUFFER, temp, "%s:\n", prefix); |
Alyssa Rosenzweig | f4678f3 | 2019-08-22 13:27:38 -0700 | [diff] [blame] | 565 | |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 566 | if (temp.type != MALI_ATTRIBUTE_TYPE_1D_NPOT_DIVISOR) |
| 567 | continue; |
| 568 | |
| 569 | pan_unpack(cl + (i + 1) * MALI_ATTRIBUTE_BUFFER_LENGTH, |
| 570 | ATTRIBUTE_BUFFER_CONTINUATION_NPOT, temp2); |
| 571 | pan_print(pandecode_dump_stream, ATTRIBUTE_BUFFER_CONTINUATION_NPOT, |
| 572 | temp2, (pandecode_indent + 1) * 2); |
Alyssa Rosenzweig | 3b3d965 | 2019-12-19 12:28:42 -0500 | [diff] [blame] | 573 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | static mali_ptr |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 577 | pandecode_shader_address(const char *name, mali_ptr ptr) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 578 | { |
| 579 | /* TODO: Decode flags */ |
| 580 | mali_ptr shader_ptr = ptr & ~15; |
| 581 | |
| 582 | char *a = pointer_as_memory_reference(shader_ptr); |
| 583 | pandecode_prop("%s = (%s) | %d", name, a, (int) (ptr & 15)); |
| 584 | free(a); |
| 585 | |
| 586 | return shader_ptr; |
| 587 | } |
| 588 | |
Alyssa Rosenzweig | ae70538 | 2019-05-18 20:48:43 +0000 | [diff] [blame] | 589 | /* Decodes a Bifrost blend constant. See the notes in bifrost_blend_rt */ |
| 590 | |
| 591 | static unsigned |
| 592 | decode_bifrost_constant(u16 constant) |
| 593 | { |
| 594 | float lo = (float) (constant & 0xFF); |
| 595 | float hi = (float) (constant >> 8); |
| 596 | |
| 597 | return (hi / 255.0) + (lo / 65535.0); |
| 598 | } |
| 599 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 600 | static mali_ptr |
| 601 | pandecode_bifrost_blend(void *descs, int job_no, int rt_no) |
| 602 | { |
| 603 | struct bifrost_blend_rt *b = |
| 604 | ((struct bifrost_blend_rt *) descs) + rt_no; |
| 605 | |
| 606 | pandecode_log("struct bifrost_blend_rt blend_rt_%d_%d = {\n", job_no, rt_no); |
| 607 | pandecode_indent++; |
| 608 | |
Alyssa Rosenzweig | ae70538 | 2019-05-18 20:48:43 +0000 | [diff] [blame] | 609 | pandecode_prop("flags = 0x%" PRIx16, b->flags); |
| 610 | pandecode_prop("constant = 0x%" PRIx8 " /* %f */", |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 611 | b->constant, decode_bifrost_constant(b->constant)); |
Alyssa Rosenzweig | ae70538 | 2019-05-18 20:48:43 +0000 | [diff] [blame] | 612 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 613 | /* TODO figure out blend shader enable bit */ |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 614 | DUMP_CL(BLEND_EQUATION, &b->equation, "Equation:\n"); |
Tomeu Vizoso | 3c98c45 | 2020-04-24 08:40:51 +0200 | [diff] [blame] | 615 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 616 | pandecode_prop("unk2 = 0x%" PRIx16, b->unk2); |
| 617 | pandecode_prop("index = 0x%" PRIx16, b->index); |
Tomeu Vizoso | 3c98c45 | 2020-04-24 08:40:51 +0200 | [diff] [blame] | 618 | |
Alyssa Rosenzweig | 0c621dc | 2020-08-11 21:30:46 -0400 | [diff] [blame] | 619 | pandecode_log(".format = %s", mali_format_as_str(b->format)); |
Tomeu Vizoso | 3c98c45 | 2020-04-24 08:40:51 +0200 | [diff] [blame] | 620 | pandecode_swizzle(b->swizzle, b->format); |
| 621 | pandecode_log_cont(",\n"); |
| 622 | |
| 623 | pandecode_prop("swizzle = 0x%" PRIx32, b->swizzle); |
| 624 | pandecode_prop("format = 0x%" PRIx32, b->format); |
| 625 | |
| 626 | if (b->zero1) { |
| 627 | pandecode_msg("XXX: pandecode_bifrost_blend zero1 tripped\n"); |
| 628 | pandecode_prop("zero1 = 0x%" PRIx32, b->zero1); |
| 629 | } |
| 630 | |
| 631 | pandecode_log(".shader_type = "); |
| 632 | switch(b->shader_type) { |
| 633 | case BIFROST_BLEND_F16: |
| 634 | pandecode_log_cont("BIFROST_BLEND_F16"); |
| 635 | break; |
| 636 | case BIFROST_BLEND_F32: |
| 637 | pandecode_log_cont("BIFROST_BLEND_F32"); |
| 638 | break; |
| 639 | case BIFROST_BLEND_I32: |
| 640 | pandecode_log_cont("BIFROST_BLEND_I32"); |
| 641 | break; |
| 642 | case BIFROST_BLEND_U32: |
| 643 | pandecode_log_cont("BIFROST_BLEND_U32"); |
| 644 | break; |
| 645 | case BIFROST_BLEND_I16: |
| 646 | pandecode_log_cont("BIFROST_BLEND_I16"); |
| 647 | break; |
| 648 | case BIFROST_BLEND_U16: |
| 649 | pandecode_log_cont("BIFROST_BLEND_U16"); |
| 650 | break; |
| 651 | } |
| 652 | pandecode_log_cont(",\n"); |
| 653 | |
| 654 | if (b->zero2) { |
| 655 | pandecode_msg("XXX: pandecode_bifrost_blend zero2 tripped\n"); |
| 656 | pandecode_prop("zero2 = 0x%" PRIx32, b->zero2); |
| 657 | } |
| 658 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 659 | pandecode_prop("shader = 0x%" PRIx32, b->shader); |
| 660 | |
| 661 | pandecode_indent--; |
| 662 | pandecode_log("},\n"); |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 663 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 664 | return 0; |
| 665 | } |
| 666 | |
| 667 | static mali_ptr |
| 668 | pandecode_midgard_blend(union midgard_blend *blend, bool is_shader) |
| 669 | { |
Alyssa Rosenzweig | 9ce45ac | 2019-08-21 08:59:57 -0700 | [diff] [blame] | 670 | /* constant/equation is in a union */ |
| 671 | if (!blend->shader) |
Alyssa Rosenzweig | b6d46d0 | 2019-06-19 09:31:16 -0700 | [diff] [blame] | 672 | return 0; |
| 673 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 674 | pandecode_log(".blend = {\n"); |
| 675 | pandecode_indent++; |
| 676 | |
| 677 | if (is_shader) { |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 678 | pandecode_shader_address("shader", blend->shader); |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 679 | } else { |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 680 | DUMP_CL(BLEND_EQUATION, &blend->equation, "Equation:\n"); |
Alyssa Rosenzweig | ae70538 | 2019-05-18 20:48:43 +0000 | [diff] [blame] | 681 | pandecode_prop("constant = %f", blend->constant); |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 682 | } |
| 683 | |
| 684 | pandecode_indent--; |
| 685 | pandecode_log("},\n"); |
| 686 | |
| 687 | /* Return blend shader to disassemble if present */ |
| 688 | return is_shader ? (blend->shader & ~0xF) : 0; |
| 689 | } |
| 690 | |
| 691 | static mali_ptr |
| 692 | pandecode_midgard_blend_mrt(void *descs, int job_no, int rt_no) |
| 693 | { |
| 694 | struct midgard_blend_rt *b = |
| 695 | ((struct midgard_blend_rt *) descs) + rt_no; |
| 696 | |
| 697 | /* Flags determine presence of blend shader */ |
Alyssa Rosenzweig | 94c9f87 | 2020-08-18 17:06:01 -0400 | [diff] [blame] | 698 | bool is_shader = b->flags.opaque[0] & 0x2; |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 699 | |
| 700 | pandecode_log("struct midgard_blend_rt blend_rt_%d_%d = {\n", job_no, rt_no); |
| 701 | pandecode_indent++; |
| 702 | |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 703 | DUMP_CL(BLEND_FLAGS, &b->flags, "Flags:\n"); |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 704 | |
Alyssa Rosenzweig | 9ffe061 | 2019-07-12 08:45:51 -0700 | [diff] [blame] | 705 | union midgard_blend blend = b->blend; |
| 706 | mali_ptr shader = pandecode_midgard_blend(&blend, is_shader); |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 707 | |
| 708 | pandecode_indent--; |
| 709 | pandecode_log("};\n"); |
| 710 | |
| 711 | return shader; |
| 712 | } |
| 713 | |
Alyssa Rosenzweig | 2208eb9 | 2019-08-20 13:59:26 -0700 | [diff] [blame] | 714 | /* Attributes and varyings have descriptor records, which contain information |
| 715 | * about their format and ordering with the attribute/varying buffers. We'll |
| 716 | * want to validate that the combinations specified are self-consistent. |
| 717 | */ |
| 718 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 719 | static int |
Alyssa Rosenzweig | 6855228 | 2020-08-26 16:50:16 -0400 | [diff] [blame] | 720 | pandecode_attribute_meta(int count, mali_ptr attribute, bool varying, char *suffix) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 721 | { |
Alyssa Rosenzweig | 6855228 | 2020-08-26 16:50:16 -0400 | [diff] [blame] | 722 | for (int i = 0; i < count; ++i, attribute += MALI_ATTRIBUTE_LENGTH) |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 723 | DUMP_ADDR(ATTRIBUTE, attribute, "%s:\n", varying ? "Varying" : "Attribute"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 724 | |
Alyssa Rosenzweig | 2c8a722 | 2020-08-13 13:27:16 -0400 | [diff] [blame] | 725 | return count; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 726 | } |
| 727 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 728 | /* return bits [lo, hi) of word */ |
| 729 | static u32 |
| 730 | bits(u32 word, u32 lo, u32 hi) |
| 731 | { |
| 732 | if (hi - lo >= 32) |
| 733 | return word; // avoid undefined behavior with the shift |
| 734 | |
| 735 | return (word >> lo) & ((1 << (hi - lo)) - 1); |
| 736 | } |
| 737 | |
| 738 | static void |
Alyssa Rosenzweig | 385a4f7 | 2019-12-24 22:33:47 -0500 | [diff] [blame] | 739 | pandecode_vertex_tiler_prefix(struct mali_vertex_tiler_prefix *p, int job_no, bool graphics) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 740 | { |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 741 | /* Decode invocation_count. See the comment before the definition of |
| 742 | * invocation_count for an explanation. |
| 743 | */ |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 744 | struct mali_invocation_packed invocation_packed = p->invocation; |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 745 | pan_unpack(&invocation_packed, INVOCATION, invocation); |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 746 | |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 747 | unsigned size_x = bits(invocation.invocations, 0, invocation.size_y_shift) + 1; |
| 748 | unsigned size_y = bits(invocation.invocations, invocation.size_y_shift, invocation.size_z_shift) + 1; |
| 749 | unsigned size_z = bits(invocation.invocations, invocation.size_z_shift, invocation.workgroups_x_shift) + 1; |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 750 | |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 751 | unsigned groups_x = bits(invocation.invocations, invocation.workgroups_x_shift, invocation.workgroups_y_shift) + 1; |
| 752 | unsigned groups_y = bits(invocation.invocations, invocation.workgroups_y_shift, invocation.workgroups_z_shift) + 1; |
| 753 | unsigned groups_z = bits(invocation.invocations, invocation.workgroups_z_shift, 32) + 1; |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 754 | |
| 755 | /* Even though we have this decoded, we want to ensure that the |
| 756 | * representation is "unique" so we don't lose anything by printing only |
| 757 | * the final result. More specifically, we need to check that we were |
| 758 | * passed something in canonical form, since the definition per the |
| 759 | * hardware is inherently not unique. How? Well, take the resulting |
| 760 | * decode and pack it ourselves! If it is bit exact with what we |
| 761 | * decoded, we're good to go. */ |
| 762 | |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 763 | struct mali_invocation_packed ref; |
Alyssa Rosenzweig | 385a4f7 | 2019-12-24 22:33:47 -0500 | [diff] [blame] | 764 | panfrost_pack_work_groups_compute(&ref, groups_x, groups_y, groups_z, size_x, size_y, size_z, graphics); |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 765 | |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 766 | if (memcmp(&ref, &invocation_packed, sizeof(ref))) { |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 767 | pandecode_msg("XXX: non-canonical workgroups packing\n"); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 768 | DUMP_UNPACKED(INVOCATION, invocation, "Invocation:\n") |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 769 | } |
| 770 | |
| 771 | /* Regardless, print the decode */ |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 772 | pandecode_log("Invocation (%d, %d, %d) x (%d, %d, %d)\n", |
| 773 | size_x, size_y, size_z, |
| 774 | groups_x, groups_y, groups_z); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 775 | |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 776 | struct mali_primitive_packed prim_packed = p->primitive; |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 777 | pan_unpack(&prim_packed, PRIMITIVE, primitive); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 778 | DUMP_UNPACKED(PRIMITIVE, primitive, "Primitive:\n"); |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 779 | |
| 780 | /* Validate an index buffer is present if we need one. TODO: verify |
| 781 | * relationship between invocation_count and index_count */ |
| 782 | |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 783 | if (primitive.indices) { |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 784 | /* Grab the size */ |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 785 | unsigned size = (primitive.index_type == MALI_INDEX_TYPE_UINT32) ? |
| 786 | sizeof(uint32_t) : primitive.index_type; |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 787 | |
| 788 | /* Ensure we got a size, and if so, validate the index buffer |
| 789 | * is large enough to hold a full set of indices of the given |
| 790 | * size */ |
| 791 | |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 792 | if (!size) |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 793 | pandecode_msg("XXX: index size missing\n"); |
| 794 | else |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 795 | pandecode_validate_buffer(primitive.indices, primitive.index_count * size); |
| 796 | } else if (primitive.index_type) |
| 797 | pandecode_msg("XXX: unexpected index size\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 798 | } |
| 799 | |
| 800 | static void |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 801 | pandecode_uniform_buffers(mali_ptr pubufs, int ubufs_count, int job_no) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 802 | { |
| 803 | struct pandecode_mapped_memory *umem = pandecode_find_mapped_gpu_mem_containing(pubufs); |
Alyssa Rosenzweig | 7d3c48f | 2020-02-16 17:01:02 -0500 | [diff] [blame] | 804 | uint64_t *PANDECODE_PTR_VAR(ubufs, umem, pubufs); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 805 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 806 | for (int i = 0; i < ubufs_count; i++) { |
Alyssa Rosenzweig | 7d3c48f | 2020-02-16 17:01:02 -0500 | [diff] [blame] | 807 | unsigned size = (ubufs[i] & ((1 << 10) - 1)) * 16; |
| 808 | mali_ptr addr = (ubufs[i] >> 10) << 2; |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 809 | |
| 810 | pandecode_validate_buffer(addr, size); |
| 811 | |
Alyssa Rosenzweig | 7d3c48f | 2020-02-16 17:01:02 -0500 | [diff] [blame] | 812 | char *ptr = pointer_as_memory_reference(addr); |
Alyssa Rosenzweig | 6ec33b4 | 2019-08-21 11:46:06 -0700 | [diff] [blame] | 813 | pandecode_log("ubuf_%d[%u] = %s;\n", i, size, ptr); |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 814 | free(ptr); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 815 | } |
| 816 | |
Alyssa Rosenzweig | 6ec33b4 | 2019-08-21 11:46:06 -0700 | [diff] [blame] | 817 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 818 | } |
| 819 | |
| 820 | static void |
Alyssa Rosenzweig | ae84f16 | 2019-08-22 11:30:13 -0700 | [diff] [blame] | 821 | pandecode_uniforms(mali_ptr uniforms, unsigned uniform_count) |
| 822 | { |
| 823 | pandecode_validate_buffer(uniforms, uniform_count * 16); |
| 824 | |
| 825 | char *ptr = pointer_as_memory_reference(uniforms); |
| 826 | pandecode_log("vec4 uniforms[%u] = %s;\n", uniform_count, ptr); |
| 827 | free(ptr); |
| 828 | } |
| 829 | |
Alyssa Rosenzweig | 09671c8 | 2019-12-23 11:40:40 -0500 | [diff] [blame] | 830 | static const char * |
| 831 | shader_type_for_job(unsigned type) |
| 832 | { |
| 833 | switch (type) { |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 834 | case MALI_JOB_TYPE_VERTEX: return "VERTEX"; |
| 835 | case MALI_JOB_TYPE_TILER: return "FRAGMENT"; |
| 836 | case MALI_JOB_TYPE_COMPUTE: return "COMPUTE"; |
Alyssa Rosenzweig | 8004906 | 2020-08-26 16:52:53 -0400 | [diff] [blame] | 837 | default: return "UNKNOWN"; |
Alyssa Rosenzweig | 09671c8 | 2019-12-23 11:40:40 -0500 | [diff] [blame] | 838 | } |
| 839 | } |
| 840 | |
Alyssa Rosenzweig | c4a4f3d | 2019-08-14 09:19:54 -0700 | [diff] [blame] | 841 | static unsigned shader_id = 0; |
| 842 | |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 843 | static struct midgard_disasm_stats |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 844 | pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type, |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 845 | bool is_bifrost, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 846 | { |
| 847 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(shader_ptr); |
| 848 | uint8_t *PANDECODE_PTR_VAR(code, mem, shader_ptr); |
| 849 | |
| 850 | /* Compute maximum possible size */ |
| 851 | size_t sz = mem->length - (shader_ptr - mem->gpu_va); |
| 852 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 853 | /* Print some boilerplate to clearly denote the assembly (which doesn't |
| 854 | * obey indentation rules), and actually do the disassembly! */ |
| 855 | |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 856 | pandecode_log_cont("\n\n"); |
Alyssa Rosenzweig | 50382df | 2019-05-18 18:58:56 +0000 | [diff] [blame] | 857 | |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 858 | struct midgard_disasm_stats stats; |
Alyssa Rosenzweig | c4a4f3d | 2019-08-14 09:19:54 -0700 | [diff] [blame] | 859 | |
Alyssa Rosenzweig | 50382df | 2019-05-18 18:58:56 +0000 | [diff] [blame] | 860 | if (is_bifrost) { |
Alyssa Rosenzweig | c88f816 | 2020-03-27 22:34:15 -0400 | [diff] [blame] | 861 | disassemble_bifrost(pandecode_dump_stream, code, sz, true); |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 862 | |
| 863 | /* TODO: Extend stats to Bifrost */ |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 864 | stats.texture_count = -128; |
| 865 | stats.sampler_count = -128; |
| 866 | stats.attribute_count = -128; |
| 867 | stats.varying_count = -128; |
| 868 | stats.uniform_count = -128; |
| 869 | stats.uniform_buffer_count = -128; |
| 870 | stats.work_count = -128; |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 871 | |
| 872 | stats.instruction_count = 0; |
| 873 | stats.bundle_count = 0; |
| 874 | stats.quadword_count = 0; |
Alyssa Rosenzweig | d6d6d63 | 2019-08-30 17:00:09 -0700 | [diff] [blame] | 875 | stats.helper_invocations = false; |
Alyssa Rosenzweig | 50382df | 2019-05-18 18:58:56 +0000 | [diff] [blame] | 876 | } else { |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 877 | stats = disassemble_midgard(pandecode_dump_stream, |
| 878 | code, sz, gpu_id, |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 879 | type == MALI_JOB_TYPE_TILER ? |
Alyssa Rosenzweig | ac14fac | 2019-11-07 09:31:02 -0500 | [diff] [blame] | 880 | MESA_SHADER_FRAGMENT : MESA_SHADER_VERTEX); |
Alyssa Rosenzweig | 50382df | 2019-05-18 18:58:56 +0000 | [diff] [blame] | 881 | } |
| 882 | |
Alyssa Rosenzweig | c088a3b | 2020-08-26 16:52:23 -0400 | [diff] [blame] | 883 | unsigned nr_threads = |
| 884 | (stats.work_count <= 4) ? 4 : |
| 885 | (stats.work_count <= 8) ? 2 : |
| 886 | 1; |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 887 | |
Alyssa Rosenzweig | c088a3b | 2020-08-26 16:52:23 -0400 | [diff] [blame] | 888 | pandecode_log_cont("shader%d - MESA_SHADER_%s shader: " |
| 889 | "%u inst, %u bundles, %u quadwords, " |
| 890 | "%u registers, %u threads, 0 loops, 0:0 spills:fills\n\n\n", |
| 891 | shader_id++, |
| 892 | shader_type_for_job(type), |
| 893 | stats.instruction_count, stats.bundle_count, stats.quadword_count, |
| 894 | stats.work_count, nr_threads); |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 895 | |
| 896 | return stats; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 897 | } |
| 898 | |
| 899 | static void |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 900 | pandecode_texture_payload(mali_ptr payload, |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 901 | enum mali_texture_dimension dim, |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 902 | enum mali_texture_layout layout, |
| 903 | bool manual_stride, |
| 904 | uint8_t levels, |
| 905 | uint16_t depth, |
| 906 | uint16_t array_size, |
| 907 | struct pandecode_mapped_memory *tmem) |
| 908 | { |
| 909 | pandecode_log(".payload = {\n"); |
| 910 | pandecode_indent++; |
| 911 | |
| 912 | /* A bunch of bitmap pointers follow. |
| 913 | * We work out the correct number, |
| 914 | * based on the mipmap/cubemap |
| 915 | * properties, but dump extra |
| 916 | * possibilities to futureproof */ |
| 917 | |
| 918 | int bitmap_count = levels + 1; |
| 919 | |
| 920 | /* Miptree for each face */ |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 921 | if (dim == MALI_TEXTURE_DIMENSION_CUBE) |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 922 | bitmap_count *= 6; |
Alyssa Rosenzweig | eba9bcd | 2020-06-30 16:21:30 -0400 | [diff] [blame] | 923 | |
| 924 | /* Array of layers */ |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 925 | bitmap_count *= depth; |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 926 | |
| 927 | /* Array of textures */ |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 928 | bitmap_count *= array_size; |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 929 | |
| 930 | /* Stride for each element */ |
| 931 | if (manual_stride) |
| 932 | bitmap_count *= 2; |
| 933 | |
| 934 | mali_ptr *pointers_and_strides = pandecode_fetch_gpu_mem(tmem, |
| 935 | payload, sizeof(mali_ptr) * bitmap_count); |
| 936 | for (int i = 0; i < bitmap_count; ++i) { |
| 937 | /* How we dump depends if this is a stride or a pointer */ |
| 938 | |
| 939 | if (manual_stride && (i & 1)) { |
| 940 | /* signed 32-bit snuck in as a 64-bit pointer */ |
| 941 | uint64_t stride_set = pointers_and_strides[i]; |
| 942 | uint32_t clamped_stride = stride_set; |
| 943 | int32_t stride = clamped_stride; |
| 944 | assert(stride_set == clamped_stride); |
| 945 | pandecode_log("(mali_ptr) %d /* stride */, \n", stride); |
| 946 | } else { |
| 947 | char *a = pointer_as_memory_reference(pointers_and_strides[i]); |
| 948 | pandecode_log("%s, \n", a); |
| 949 | free(a); |
| 950 | } |
| 951 | } |
| 952 | |
| 953 | pandecode_indent--; |
| 954 | pandecode_log("},\n"); |
| 955 | } |
| 956 | |
| 957 | static void |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 958 | pandecode_texture(mali_ptr u, |
| 959 | struct pandecode_mapped_memory *tmem, |
| 960 | unsigned job_no, unsigned tex) |
| 961 | { |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 962 | struct pandecode_mapped_memory *mapped_mem = pandecode_find_mapped_gpu_mem_containing(u); |
| 963 | const uint8_t *cl = pandecode_fetch_gpu_mem(mapped_mem, u, MALI_MIDGARD_TEXTURE_LENGTH); |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 964 | |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 965 | pan_unpack(cl, MIDGARD_TEXTURE, temp); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 966 | DUMP_UNPACKED(MIDGARD_TEXTURE, temp, "Texture:\n") |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 967 | |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 968 | pandecode_indent++; |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 969 | pandecode_texture_payload(u + MALI_MIDGARD_TEXTURE_LENGTH, |
| 970 | temp.dimension, temp.texel_ordering, temp.manual_stride, |
| 971 | temp.levels, temp.depth, temp.array_size, mapped_mem); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 972 | pandecode_indent--; |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 973 | } |
| 974 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 975 | static void |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 976 | pandecode_bifrost_texture( |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 977 | const void *cl, |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 978 | unsigned job_no, |
| 979 | unsigned tex) |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 980 | { |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 981 | pan_unpack(cl, BIFROST_TEXTURE, temp); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 982 | DUMP_UNPACKED(BIFROST_TEXTURE, temp, "Texture:\n") |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 983 | |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 984 | struct pandecode_mapped_memory *tmem = pandecode_find_mapped_gpu_mem_containing(temp.surfaces); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 985 | pandecode_indent++; |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 986 | pandecode_texture_payload(temp.surfaces, temp.dimension, temp.texel_ordering, |
| 987 | true, temp.levels, 1, 1, tmem); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 988 | pandecode_indent--; |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 989 | } |
| 990 | |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 991 | /* For shader properties like texture_count, we have a claimed property in the shader_meta, and the actual Truth from static analysis (this may just be an upper limit). We validate accordingly */ |
| 992 | |
| 993 | static void |
| 994 | pandecode_shader_prop(const char *name, unsigned claim, signed truth, bool fuzzy) |
| 995 | { |
| 996 | /* Nothing to do */ |
| 997 | if (claim == truth) |
| 998 | return; |
| 999 | |
Alyssa Rosenzweig | 5815f33 | 2020-02-25 17:29:55 -0500 | [diff] [blame] | 1000 | if (fuzzy && (truth < 0)) |
| 1001 | pandecode_msg("XXX: fuzzy %s, claimed %d, expected %d\n", name, claim, truth); |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1002 | |
| 1003 | if ((truth >= 0) && !fuzzy) { |
Alyssa Rosenzweig | f48136e | 2019-08-22 09:02:48 -0700 | [diff] [blame] | 1004 | pandecode_msg("%s: expected %s = %d, claimed %u\n", |
| 1005 | (truth < claim) ? "warn" : "XXX", |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1006 | name, truth, claim); |
| 1007 | } else if ((claim > -truth) && !fuzzy) { |
| 1008 | pandecode_msg("XXX: expected %s <= %u, claimed %u\n", |
| 1009 | name, -truth, claim); |
| 1010 | } else if (fuzzy && (claim < truth)) |
| 1011 | pandecode_msg("XXX: expected %s >= %u, claimed %u\n", |
| 1012 | name, truth, claim); |
| 1013 | |
| 1014 | pandecode_log(".%s = %" PRId16, name, claim); |
| 1015 | |
| 1016 | if (fuzzy) |
| 1017 | pandecode_log_cont(" /* %u used */", truth); |
| 1018 | |
| 1019 | pandecode_log_cont(",\n"); |
| 1020 | } |
| 1021 | |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 1022 | static void |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 1023 | pandecode_blend_shader_disassemble(mali_ptr shader, int job_no, int job_type, |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1024 | bool is_bifrost, unsigned gpu_id) |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 1025 | { |
| 1026 | struct midgard_disasm_stats stats = |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1027 | pandecode_shader_disassemble(shader, job_no, job_type, is_bifrost, gpu_id); |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 1028 | |
| 1029 | bool has_texture = (stats.texture_count > 0); |
| 1030 | bool has_sampler = (stats.sampler_count > 0); |
| 1031 | bool has_attribute = (stats.attribute_count > 0); |
| 1032 | bool has_varying = (stats.varying_count > 0); |
| 1033 | bool has_uniform = (stats.uniform_count > 0); |
| 1034 | bool has_ubo = (stats.uniform_buffer_count > 0); |
| 1035 | |
| 1036 | if (has_texture || has_sampler) |
| 1037 | pandecode_msg("XXX: blend shader accessing textures\n"); |
| 1038 | |
| 1039 | if (has_attribute || has_varying) |
| 1040 | pandecode_msg("XXX: blend shader accessing interstage\n"); |
| 1041 | |
| 1042 | if (has_uniform || has_ubo) |
| 1043 | pandecode_msg("XXX: blend shader accessing uniforms\n"); |
| 1044 | } |
| 1045 | |
| 1046 | static void |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1047 | pandecode_textures(mali_ptr textures, unsigned texture_count, int job_no, bool is_bifrost) |
| 1048 | { |
| 1049 | struct pandecode_mapped_memory *mmem = pandecode_find_mapped_gpu_mem_containing(textures); |
| 1050 | |
| 1051 | if (!mmem) |
| 1052 | return; |
| 1053 | |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 1054 | pandecode_log("Textures (%"PRIx64"):\n", textures); |
| 1055 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1056 | if (is_bifrost) { |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 1057 | const void *cl = pandecode_fetch_gpu_mem(mmem, |
| 1058 | textures, MALI_BIFROST_TEXTURE_LENGTH * |
| 1059 | texture_count); |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1060 | |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 1061 | for (unsigned tex = 0; tex < texture_count; ++tex) { |
| 1062 | pandecode_bifrost_texture(cl + |
| 1063 | MALI_BIFROST_TEXTURE_LENGTH * tex, |
| 1064 | job_no, tex); |
| 1065 | } |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1066 | } else { |
| 1067 | mali_ptr *PANDECODE_PTR_VAR(u, mmem, textures); |
| 1068 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1069 | for (int tex = 0; tex < texture_count; ++tex) { |
| 1070 | mali_ptr *PANDECODE_PTR_VAR(u, mmem, textures + tex * sizeof(mali_ptr)); |
| 1071 | char *a = pointer_as_memory_reference(*u); |
| 1072 | pandecode_log("%s,\n", a); |
| 1073 | free(a); |
| 1074 | } |
| 1075 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1076 | /* Now, finally, descend down into the texture descriptor */ |
| 1077 | for (unsigned tex = 0; tex < texture_count; ++tex) { |
| 1078 | mali_ptr *PANDECODE_PTR_VAR(u, mmem, textures + tex * sizeof(mali_ptr)); |
| 1079 | struct pandecode_mapped_memory *tmem = pandecode_find_mapped_gpu_mem_containing(*u); |
| 1080 | if (tmem) |
| 1081 | pandecode_texture(*u, tmem, job_no, tex); |
| 1082 | } |
| 1083 | } |
| 1084 | } |
| 1085 | |
| 1086 | static void |
| 1087 | pandecode_samplers(mali_ptr samplers, unsigned sampler_count, int job_no, bool is_bifrost) |
| 1088 | { |
Alyssa Rosenzweig | b10c3c8 | 2020-08-11 18:25:03 -0400 | [diff] [blame] | 1089 | for (int i = 0; i < sampler_count; ++i) { |
| 1090 | if (is_bifrost) { |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1091 | DUMP_ADDR(BIFROST_SAMPLER, samplers + (MALI_BIFROST_SAMPLER_LENGTH * i), "Sampler:\n"); |
Alyssa Rosenzweig | b10c3c8 | 2020-08-11 18:25:03 -0400 | [diff] [blame] | 1092 | } else { |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1093 | DUMP_ADDR(MIDGARD_SAMPLER, samplers + (MALI_MIDGARD_SAMPLER_LENGTH * i), "Sampler:\n"); |
Alyssa Rosenzweig | b10c3c8 | 2020-08-11 18:25:03 -0400 | [diff] [blame] | 1094 | } |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1095 | } |
| 1096 | } |
| 1097 | |
| 1098 | static void |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 1099 | pandecode_vertex_tiler_postfix_pre( |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1100 | const struct MALI_DRAW *p, |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 1101 | int job_no, enum mali_job_type job_type, |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1102 | char *suffix, bool is_bifrost, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1103 | { |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1104 | struct pandecode_mapped_memory *attr_mem; |
| 1105 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1106 | struct pandecode_fbd fbd_info = { |
| 1107 | /* Default for Bifrost */ |
| 1108 | .rt_count = 1 |
| 1109 | }; |
| 1110 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1111 | if (is_bifrost) |
| 1112 | pandecode_compute_fbd(p->shared & ~1, job_no); |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1113 | else if (p->shared & MALI_FBD_TAG_IS_MFBD) |
| 1114 | fbd_info = pandecode_mfbd_bfr((u64) ((uintptr_t) p->shared) & ~MALI_FBD_TAG_MASK, |
| 1115 | job_no, false, job_type == MALI_JOB_TYPE_COMPUTE, is_bifrost, gpu_id); |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1116 | else if (job_type == MALI_JOB_TYPE_COMPUTE) |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1117 | pandecode_compute_fbd((u64) (uintptr_t) p->shared, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1118 | else |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1119 | fbd_info = pandecode_sfbd((u64) (uintptr_t) p->shared, job_no, false, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1120 | |
| 1121 | int varying_count = 0, attribute_count = 0, uniform_count = 0, uniform_buffer_count = 0; |
| 1122 | int texture_count = 0, sampler_count = 0; |
| 1123 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1124 | if (p->state) { |
| 1125 | struct pandecode_mapped_memory *smem = pandecode_find_mapped_gpu_mem_containing(p->state); |
| 1126 | uint32_t *cl = pandecode_fetch_gpu_mem(smem, p->state, MALI_STATE_LENGTH); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1127 | |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1128 | /* Disassemble ahead-of-time to get stats. Initialize with |
| 1129 | * stats for the missing-shader case so we get validation |
| 1130 | * there, too */ |
| 1131 | |
| 1132 | struct midgard_disasm_stats info = { |
| 1133 | .texture_count = 0, |
| 1134 | .sampler_count = 0, |
| 1135 | .attribute_count = 0, |
| 1136 | .varying_count = 0, |
| 1137 | .work_count = 1, |
| 1138 | |
| 1139 | .uniform_count = -128, |
| 1140 | .uniform_buffer_count = 0 |
| 1141 | }; |
Alyssa Rosenzweig | 9b067d9 | 2019-08-21 14:28:36 -0700 | [diff] [blame] | 1142 | |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1143 | pan_unpack(cl, STATE, state); |
Alyssa Rosenzweig | 661b469 | 2020-08-21 10:34:06 -0400 | [diff] [blame] | 1144 | |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1145 | if (state.shader.shader & ~0xF) |
| 1146 | info = pandecode_shader_disassemble(state.shader.shader & ~0xF, job_no, job_type, is_bifrost, gpu_id); |
Alyssa Rosenzweig | 661b469 | 2020-08-21 10:34:06 -0400 | [diff] [blame] | 1147 | |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1148 | DUMP_UNPACKED(STATE, state, "State:\n"); |
| 1149 | pandecode_indent++; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1150 | |
| 1151 | /* Save for dumps */ |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1152 | attribute_count = state.shader.attribute_count; |
| 1153 | varying_count = state.shader.varying_count; |
| 1154 | texture_count = state.shader.texture_count; |
| 1155 | sampler_count = state.shader.sampler_count; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1156 | |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1157 | fprintf(pandecode_dump_stream, " Properties\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1158 | if (is_bifrost) { |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1159 | pan_unpack(&state.properties, BIFROST_PROPERTIES, bi_props); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1160 | DUMP_UNPACKED(BIFROST_PROPERTIES, bi_props, "Properties:\n"); |
Alyssa Rosenzweig | acf77cb | 2020-08-20 16:41:41 -0400 | [diff] [blame] | 1161 | |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1162 | uniform_count = state.preload.uniform_count; |
Alyssa Rosenzweig | acf77cb | 2020-08-20 16:41:41 -0400 | [diff] [blame] | 1163 | uniform_buffer_count = bi_props.uniform_buffer_count; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1164 | } else { |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1165 | pan_unpack(&state.properties, MIDGARD_PROPERTIES, midg_props); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1166 | DUMP_UNPACKED(MIDGARD_PROPERTIES, midg_props, "Properties:\n") |
Alyssa Rosenzweig | 1b7d4f1 | 2020-08-20 16:25:14 -0400 | [diff] [blame] | 1167 | |
| 1168 | uniform_count = midg_props.uniform_count; |
| 1169 | uniform_buffer_count = midg_props.uniform_buffer_count; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1170 | } |
| 1171 | |
Alyssa Rosenzweig | 661b469 | 2020-08-21 10:34:06 -0400 | [diff] [blame] | 1172 | pandecode_shader_prop("texture_count", texture_count, info.texture_count, false); |
| 1173 | pandecode_shader_prop("sampler_count", sampler_count, info.sampler_count, false); |
| 1174 | pandecode_shader_prop("attribute_count", attribute_count, info.attribute_count, false); |
| 1175 | pandecode_shader_prop("varying_count", varying_count, info.varying_count, false); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1176 | |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 1177 | if (is_bifrost) { |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1178 | uint32_t opaque = state.preload.uniform_count << 15 |
| 1179 | | state.preload.untyped; |
| 1180 | |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 1181 | switch (job_type) { |
| 1182 | case MALI_JOB_TYPE_VERTEX: |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1183 | DUMP_CL(PRELOAD_VERTEX, &opaque, "Preload:\n"); |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 1184 | break; |
| 1185 | case MALI_JOB_TYPE_TILER: |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1186 | DUMP_CL(PRELOAD_FRAGMENT, &opaque, "Preload:\n"); |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 1187 | break; |
| 1188 | case MALI_JOB_TYPE_COMPUTE: |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1189 | DUMP_CL(PRELOAD_COMPUTE, &opaque, "Preload:\n"); |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 1190 | break; |
| 1191 | default: |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1192 | DUMP_CL(PRELOAD, &opaque, "Preload:\n"); |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 1193 | break; |
| 1194 | } |
| 1195 | } |
| 1196 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1197 | if (!is_bifrost) { |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1198 | /* TODO: Blend shaders routing/disasm */ |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1199 | union midgard_blend blend; |
| 1200 | memcpy(&blend, &state.sfbd_blend, sizeof(blend)); |
| 1201 | mali_ptr shader = pandecode_midgard_blend(&blend, state.multisample_misc.sfbd_blend_shader); |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 1202 | if (shader & ~0xF) |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1203 | pandecode_blend_shader_disassemble(shader, job_no, job_type, false, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1204 | } |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1205 | pandecode_indent--; |
| 1206 | pandecode_msg("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1207 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1208 | /* MRT blend fields are used whenever MFBD is used, with |
| 1209 | * per-RT descriptors */ |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1210 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1211 | if (job_type == MALI_JOB_TYPE_TILER && |
| 1212 | (is_bifrost || p->shared & MALI_FBD_TAG_IS_MFBD)) { |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1213 | void* blend_base = ((void *) cl) + MALI_STATE_LENGTH; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1214 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1215 | for (unsigned i = 0; i < fbd_info.rt_count; i++) { |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1216 | mali_ptr shader = 0; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1217 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1218 | if (is_bifrost) |
| 1219 | shader = pandecode_bifrost_blend(blend_base, job_no, i); |
| 1220 | else |
| 1221 | shader = pandecode_midgard_blend_mrt(blend_base, job_no, i); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1222 | |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 1223 | if (shader & ~0xF) |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1224 | pandecode_blend_shader_disassemble(shader, job_no, job_type, false, gpu_id); |
Alyssa Rosenzweig | 139708b | 2019-08-21 14:04:05 -0700 | [diff] [blame] | 1225 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1226 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1227 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1228 | } else |
Alyssa Rosenzweig | 5f9a1c7 | 2019-08-21 14:16:32 -0700 | [diff] [blame] | 1229 | pandecode_msg("XXX: missing shader descriptor\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1230 | |
Alyssa Rosenzweig | 7f487e0 | 2020-08-05 19:33:20 -0400 | [diff] [blame] | 1231 | if (p->viewport) |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1232 | DUMP_ADDR(VIEWPORT, p->viewport, "Viewport:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1233 | |
Alyssa Rosenzweig | ed464e0 | 2019-08-22 13:07:01 -0700 | [diff] [blame] | 1234 | unsigned max_attr_index = 0; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1235 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1236 | if (p->attributes) |
| 1237 | max_attr_index = pandecode_attribute_meta(attribute_count, p->attributes, false, suffix); |
Alyssa Rosenzweig | ed464e0 | 2019-08-22 13:07:01 -0700 | [diff] [blame] | 1238 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1239 | if (p->attribute_buffers) { |
| 1240 | attr_mem = pandecode_find_mapped_gpu_mem_containing(p->attribute_buffers); |
| 1241 | pandecode_attributes(attr_mem, p->attribute_buffers, job_no, suffix, max_attr_index, false, job_type); |
Alyssa Rosenzweig | 9e66ff3 | 2019-07-31 11:52:52 -0700 | [diff] [blame] | 1242 | } |
| 1243 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1244 | if (p->varyings) { |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1245 | varying_count = pandecode_attribute_meta(varying_count, p->varyings, true, suffix); |
| 1246 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1247 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1248 | if (p->varying_buffers) { |
| 1249 | attr_mem = pandecode_find_mapped_gpu_mem_containing(p->varying_buffers); |
| 1250 | pandecode_attributes(attr_mem, p->varying_buffers, job_no, suffix, varying_count, true, job_type); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1251 | } |
| 1252 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1253 | if (p->uniform_buffers) { |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1254 | if (uniform_buffer_count) |
| 1255 | pandecode_uniform_buffers(p->uniform_buffers, uniform_buffer_count, job_no); |
| 1256 | else |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1257 | pandecode_msg("warn: UBOs specified but not referenced\n"); |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1258 | } else if (uniform_buffer_count) |
| 1259 | pandecode_msg("XXX: UBOs referenced but not specified\n"); |
| 1260 | |
| 1261 | /* We don't want to actually dump uniforms, but we do need to validate |
| 1262 | * that the counts we were given are sane */ |
| 1263 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1264 | if (p->push_uniforms) { |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1265 | if (uniform_count) |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1266 | pandecode_uniforms(p->push_uniforms, uniform_count); |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1267 | else |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1268 | pandecode_msg("warn: Uniforms specified but not referenced\n"); |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1269 | } else if (uniform_count) |
Alyssa Rosenzweig | d7473e2 | 2019-08-21 14:15:05 -0700 | [diff] [blame] | 1270 | pandecode_msg("XXX: Uniforms referenced but not specified\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1271 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1272 | if (p->textures) |
| 1273 | pandecode_textures(p->textures, texture_count, job_no, is_bifrost); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1274 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1275 | if (p->samplers) |
| 1276 | pandecode_samplers(p->samplers, sampler_count, job_no, is_bifrost); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1277 | } |
| 1278 | |
| 1279 | static void |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1280 | pandecode_bifrost_tiler_heap(mali_ptr gpu_va, int job_no) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1281 | { |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1282 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1283 | pan_unpack(PANDECODE_PTR(mem, gpu_va, void), BIFROST_TILER_HEAP, h); |
| 1284 | DUMP_UNPACKED(BIFROST_TILER_HEAP, h, "Bifrost Tiler Heap:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1285 | } |
| 1286 | |
| 1287 | static void |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1288 | pandecode_bifrost_tiler(mali_ptr gpu_va, int job_no) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1289 | { |
| 1290 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1291 | pan_unpack(PANDECODE_PTR(mem, gpu_va, void), BIFROST_TILER, t); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1292 | |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1293 | pandecode_bifrost_tiler_heap(t.heap, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1294 | |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1295 | DUMP_UNPACKED(BIFROST_TILER, t, "Bifrost Tiler:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1296 | pandecode_indent++; |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1297 | if (t.hierarchy_mask != 0xa && |
| 1298 | t.hierarchy_mask != 0x14 && |
| 1299 | t.hierarchy_mask != 0x28 && |
| 1300 | t.hierarchy_mask != 0x50 && |
| 1301 | t.hierarchy_mask != 0xa0) |
Tomeu Vizoso | 0a0b670 | 2020-04-09 09:39:17 +0200 | [diff] [blame] | 1302 | pandecode_prop("XXX: Unexpected hierarchy_mask (not 0xa, 0x14, 0x28, 0x50 or 0xa0)!"); |
| 1303 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1304 | pandecode_indent--; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1305 | } |
| 1306 | |
| 1307 | static void |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 1308 | pandecode_primitive_size(union midgard_primitive_size u, bool constant) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1309 | { |
Alyssa Rosenzweig | 2608da1 | 2019-06-19 09:35:57 -0700 | [diff] [blame] | 1310 | if (u.pointer == 0x0) |
| 1311 | return; |
| 1312 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1313 | pandecode_log(".primitive_size = {\n"); |
| 1314 | pandecode_indent++; |
| 1315 | |
Alyssa Rosenzweig | b517e36 | 2019-03-15 03:21:27 +0000 | [diff] [blame] | 1316 | if (constant) { |
| 1317 | pandecode_prop("constant = %f", u.constant); |
| 1318 | } else { |
| 1319 | MEMORY_PROP((&u), pointer); |
| 1320 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1321 | |
| 1322 | pandecode_indent--; |
| 1323 | pandecode_log("},\n"); |
| 1324 | } |
| 1325 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1326 | static int |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1327 | pandecode_vertex_job_bfr(const struct MALI_JOB_HEADER *h, |
| 1328 | const struct pandecode_mapped_memory *mem, |
| 1329 | mali_ptr payload, int job_no, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1330 | { |
| 1331 | struct bifrost_payload_vertex *PANDECODE_PTR_VAR(v, mem, payload); |
| 1332 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1333 | struct mali_draw_packed draw_packed; |
| 1334 | memcpy(&draw_packed, &v->postfix, sizeof(draw_packed)); |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1335 | pan_unpack(&draw_packed, DRAW, draw); |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1336 | pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", true, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1337 | |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 1338 | pandecode_vertex_tiler_prefix(&v->prefix, job_no, false); |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1339 | DUMP_CL(DRAW, &draw_packed, "Draw:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1340 | |
| 1341 | return sizeof(*v); |
| 1342 | } |
| 1343 | |
| 1344 | static int |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1345 | pandecode_tiler_job_bfr(const struct MALI_JOB_HEADER *h, |
| 1346 | const struct pandecode_mapped_memory *mem, |
| 1347 | mali_ptr payload, int job_no, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1348 | { |
| 1349 | struct bifrost_payload_tiler *PANDECODE_PTR_VAR(t, mem, payload); |
| 1350 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1351 | struct mali_draw_packed draw_packed; |
| 1352 | memcpy(&draw_packed, &t->postfix, sizeof(draw_packed)); |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1353 | pan_unpack(&draw_packed, DRAW, draw); |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1354 | pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", true, gpu_id); |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1355 | pandecode_bifrost_tiler(t->tiler_meta, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1356 | |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 1357 | pandecode_vertex_tiler_prefix(&t->prefix, job_no, false); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1358 | |
Alyssa Rosenzweig | 4467e79 | 2020-08-26 13:21:06 -0400 | [diff] [blame] | 1359 | /* TODO: gl_PointSize on Bifrost */ |
| 1360 | pandecode_primitive_size(t->primitive_size, true); |
| 1361 | |
| 1362 | if (t->zero1 || t->zero2 || t->zero3 || t->zero4 || t->zero5 |
| 1363 | || t->zero6) { |
| 1364 | pandecode_msg("XXX: tiler only zero tripped\n"); |
| 1365 | pandecode_prop("zero1 = 0x%" PRIx64, t->zero1); |
| 1366 | pandecode_prop("zero2 = 0x%" PRIx64, t->zero2); |
| 1367 | pandecode_prop("zero3 = 0x%" PRIx64, t->zero3); |
| 1368 | pandecode_prop("zero4 = 0x%" PRIx64, t->zero4); |
| 1369 | pandecode_prop("zero5 = 0x%" PRIx64, t->zero5); |
| 1370 | pandecode_prop("zero6 = 0x%" PRIx64, t->zero6); |
| 1371 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1372 | |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1373 | DUMP_CL(DRAW, &draw_packed, "Draw:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1374 | |
| 1375 | return sizeof(*t); |
| 1376 | } |
| 1377 | |
| 1378 | static int |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1379 | pandecode_vertex_or_tiler_job_mdg(const struct MALI_JOB_HEADER *h, |
| 1380 | const struct pandecode_mapped_memory *mem, |
| 1381 | mali_ptr payload, int job_no, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1382 | { |
| 1383 | struct midgard_payload_vertex_tiler *PANDECODE_PTR_VAR(v, mem, payload); |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1384 | bool is_graphics = (h->type == MALI_JOB_TYPE_VERTEX) || (h->type == MALI_JOB_TYPE_TILER); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1385 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1386 | struct mali_draw_packed draw_packed; |
| 1387 | memcpy(&draw_packed, &v->postfix, sizeof(draw_packed)); |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1388 | pan_unpack(&draw_packed, DRAW, draw); |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1389 | pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", false, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1390 | |
Alyssa Rosenzweig | b010a6d | 2020-04-06 20:31:32 -0400 | [diff] [blame] | 1391 | pandecode_vertex_tiler_prefix(&v->prefix, job_no, is_graphics); |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1392 | DUMP_CL(DRAW, &draw_packed, "Draw:\n"); |
Alyssa Rosenzweig | b010a6d | 2020-04-06 20:31:32 -0400 | [diff] [blame] | 1393 | |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 1394 | struct mali_primitive_packed prim_packed = v->prefix.primitive; |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1395 | pan_unpack(&prim_packed, PRIMITIVE, primitive); |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 1396 | |
| 1397 | pandecode_primitive_size(v->primitive_size, primitive.point_size_array == 0); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1398 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1399 | return sizeof(*v); |
| 1400 | } |
| 1401 | |
| 1402 | static int |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 1403 | pandecode_fragment_job(const struct pandecode_mapped_memory *mem, |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 1404 | mali_ptr payload, int job_no, |
Tomeu Vizoso | 697f02c | 2019-11-12 12:15:02 +0100 | [diff] [blame] | 1405 | bool is_bifrost, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1406 | { |
| 1407 | const struct mali_payload_fragment *PANDECODE_PTR_VAR(s, mem, payload); |
| 1408 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1409 | bool is_mfbd = s->framebuffer & MALI_FBD_TAG_IS_MFBD; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1410 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1411 | if (!is_mfbd && is_bifrost) |
| 1412 | pandecode_msg("XXX: Bifrost fragment must use MFBD\n"); |
| 1413 | |
| 1414 | struct pandecode_fbd info; |
| 1415 | |
| 1416 | if (is_mfbd) |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1417 | info = pandecode_mfbd_bfr(s->framebuffer & ~MALI_FBD_TAG_MASK, job_no, |
| 1418 | true, false, is_bifrost, gpu_id); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1419 | else |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1420 | info = pandecode_sfbd(s->framebuffer & ~MALI_FBD_TAG_MASK, job_no, |
| 1421 | true, gpu_id); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1422 | |
| 1423 | /* Compute the tag for the tagged pointer. This contains the type of |
| 1424 | * FBD (MFBD/SFBD), and in the case of an MFBD, information about which |
| 1425 | * additional structures follow the MFBD header (an extra payload or |
| 1426 | * not, as well as a count of render targets) */ |
| 1427 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1428 | unsigned expected_tag = is_mfbd ? MALI_FBD_TAG_IS_MFBD : 0; |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1429 | |
| 1430 | if (is_mfbd) { |
| 1431 | if (info.has_extra) |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1432 | expected_tag |= MALI_FBD_TAG_HAS_ZS_RT; |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1433 | |
| 1434 | expected_tag |= (MALI_POSITIVE(info.rt_count) << 2); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1435 | } |
| 1436 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1437 | if ((s->min_tile_coord | s->max_tile_coord) & ~(MALI_X_COORD_MASK | MALI_Y_COORD_MASK)) { |
| 1438 | pandecode_msg("XXX: unexpected tile coordinate bits\n"); |
| 1439 | pandecode_prop("min_tile_coord = 0x%X\n", s->min_tile_coord); |
Alyssa Rosenzweig | 52d6b4d | 2020-05-11 18:54:05 -0400 | [diff] [blame] | 1440 | pandecode_prop("max_tile_coord = 0x%X\n", s->max_tile_coord); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1441 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1442 | |
Alyssa Rosenzweig | ded9a68 | 2019-08-21 12:29:47 -0700 | [diff] [blame] | 1443 | /* Extract tile coordinates */ |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1444 | |
Alyssa Rosenzweig | ded9a68 | 2019-08-21 12:29:47 -0700 | [diff] [blame] | 1445 | unsigned min_x = MALI_TILE_COORD_X(s->min_tile_coord) << MALI_TILE_SHIFT; |
| 1446 | unsigned min_y = MALI_TILE_COORD_Y(s->min_tile_coord) << MALI_TILE_SHIFT; |
| 1447 | |
| 1448 | unsigned max_x = (MALI_TILE_COORD_X(s->max_tile_coord) + 1) << MALI_TILE_SHIFT; |
| 1449 | unsigned max_y = (MALI_TILE_COORD_Y(s->max_tile_coord) + 1) << MALI_TILE_SHIFT; |
| 1450 | |
| 1451 | /* For the max, we also want the floored (rather than ceiled) version for checking */ |
| 1452 | |
| 1453 | unsigned max_x_f = (MALI_TILE_COORD_X(s->max_tile_coord)) << MALI_TILE_SHIFT; |
| 1454 | unsigned max_y_f = (MALI_TILE_COORD_Y(s->max_tile_coord)) << MALI_TILE_SHIFT; |
| 1455 | |
| 1456 | /* Validate the coordinates are well-ordered */ |
| 1457 | |
| 1458 | if (min_x == max_x) |
| 1459 | pandecode_msg("XXX: empty X coordinates (%u = %u)\n", min_x, max_x); |
| 1460 | else if (min_x > max_x) |
| 1461 | pandecode_msg("XXX: misordered X coordinates (%u > %u)\n", min_x, max_x); |
| 1462 | |
| 1463 | if (min_y == max_y) |
| 1464 | pandecode_msg("XXX: empty X coordinates (%u = %u)\n", min_x, max_x); |
| 1465 | else if (min_y > max_y) |
| 1466 | pandecode_msg("XXX: misordered X coordinates (%u > %u)\n", min_x, max_x); |
| 1467 | |
| 1468 | /* Validate the coordinates fit inside the framebuffer. We use floor, |
| 1469 | * rather than ceil, for the max coordinates, since the tile |
| 1470 | * coordinates for something like an 800x600 framebuffer will actually |
| 1471 | * resolve to 800x608, which would otherwise trigger a Y-overflow */ |
| 1472 | |
| 1473 | if ((min_x > info.width) || (max_x_f > info.width)) |
| 1474 | pandecode_msg("XXX: tile coordinates overflow in X direction\n"); |
| 1475 | |
| 1476 | if ((min_y > info.height) || (max_y_f > info.height)) |
| 1477 | pandecode_msg("XXX: tile coordinates overflow in Y direction\n"); |
| 1478 | |
| 1479 | /* After validation, we print */ |
| 1480 | |
| 1481 | pandecode_log("fragment (%u, %u) ... (%u, %u)\n\n", min_x, min_y, max_x, max_y); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1482 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1483 | /* The FBD is a tagged pointer */ |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1484 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1485 | unsigned tag = (s->framebuffer & MALI_FBD_TAG_MASK); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1486 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1487 | if (tag != expected_tag) |
| 1488 | pandecode_msg("XXX: expected FBD tag %X but got %X\n", expected_tag, tag); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1489 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1490 | return sizeof(*s); |
| 1491 | } |
| 1492 | |
Alyssa Rosenzweig | 4122f74 | 2020-02-18 07:43:51 -0500 | [diff] [blame] | 1493 | /* Entrypoint to start tracing. jc_gpu_va is the GPU address for the first job |
| 1494 | * in the chain; later jobs are found by walking the chain. Bifrost is, well, |
| 1495 | * if it's bifrost or not. GPU ID is the more finegrained ID (at some point, we |
| 1496 | * might wish to combine this with the bifrost parameter) because some details |
| 1497 | * are model-specific even within a particular architecture. Minimal traces |
| 1498 | * *only* examine the job descriptors, skipping printing entirely if there is |
| 1499 | * no faults, and only descends into the payload if there are faults. This is |
| 1500 | * useful for looking for faults without the overhead of invasive traces. */ |
| 1501 | |
Alyssa Rosenzweig | 5998646 | 2020-02-18 07:46:03 -0500 | [diff] [blame] | 1502 | void |
Alyssa Rosenzweig | 4122f74 | 2020-02-18 07:43:51 -0500 | [diff] [blame] | 1503 | pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1504 | { |
Icecream95 | 01d60d3 | 2020-07-16 16:12:13 +1200 | [diff] [blame] | 1505 | pandecode_dump_file_open(); |
| 1506 | |
Alyssa Rosenzweig | 5998646 | 2020-02-18 07:46:03 -0500 | [diff] [blame] | 1507 | unsigned job_descriptor_number = 0; |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1508 | mali_ptr next_job = 0; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1509 | |
| 1510 | do { |
| 1511 | struct pandecode_mapped_memory *mem = |
| 1512 | pandecode_find_mapped_gpu_mem_containing(jc_gpu_va); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1513 | void *payload; |
| 1514 | |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1515 | pan_unpack(PANDECODE_PTR(mem, jc_gpu_va, struct mali_job_header_packed), |
| 1516 | JOB_HEADER, h); |
| 1517 | next_job = h.next; |
| 1518 | mali_ptr payload_ptr = jc_gpu_va + MALI_JOB_HEADER_LENGTH; |
Alyssa Rosenzweig | d353b15 | 2020-08-21 09:36:14 -0400 | [diff] [blame] | 1519 | payload = pandecode_fetch_gpu_mem(mem, payload_ptr, 64); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1520 | |
| 1521 | int job_no = job_descriptor_number++; |
| 1522 | |
Alyssa Rosenzweig | 4122f74 | 2020-02-18 07:43:51 -0500 | [diff] [blame] | 1523 | /* If the job is good to go, skip it in minimal mode */ |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1524 | if (minimal && (h.exception_status == 0x0 || h.exception_status == 0x1)) |
Alyssa Rosenzweig | 4122f74 | 2020-02-18 07:43:51 -0500 | [diff] [blame] | 1525 | continue; |
| 1526 | |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1527 | DUMP_UNPACKED(JOB_HEADER, h, "Job Header:\n"); |
| 1528 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1529 | |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1530 | switch (h.type) { |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1531 | case MALI_JOB_TYPE_WRITE_VALUE: { |
Alyssa Rosenzweig | adf716d | 2019-12-05 09:06:53 -0500 | [diff] [blame] | 1532 | struct mali_payload_write_value *s = payload; |
| 1533 | pandecode_log("struct mali_payload_write_value payload_%"PRIx64"_%d = {\n", payload_ptr, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1534 | pandecode_indent++; |
Alyssa Rosenzweig | 9eae950 | 2019-12-04 08:59:29 -0500 | [diff] [blame] | 1535 | MEMORY_PROP(s, address); |
| 1536 | |
Alyssa Rosenzweig | adf716d | 2019-12-05 09:06:53 -0500 | [diff] [blame] | 1537 | if (s->value_descriptor != MALI_WRITE_VALUE_ZERO) { |
Alyssa Rosenzweig | 9eae950 | 2019-12-04 08:59:29 -0500 | [diff] [blame] | 1538 | pandecode_msg("XXX: unknown value descriptor\n"); |
| 1539 | pandecode_prop("value_descriptor = 0x%" PRIX32, s->value_descriptor); |
| 1540 | } |
| 1541 | |
| 1542 | if (s->reserved) { |
| 1543 | pandecode_msg("XXX: set value tripped\n"); |
| 1544 | pandecode_prop("reserved = 0x%" PRIX32, s->reserved); |
| 1545 | } |
| 1546 | |
| 1547 | pandecode_prop("immediate = 0x%" PRIX64, s->immediate); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1548 | pandecode_indent--; |
| 1549 | pandecode_log("};\n"); |
| 1550 | |
| 1551 | break; |
| 1552 | } |
| 1553 | |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1554 | case MALI_JOB_TYPE_TILER: |
| 1555 | case MALI_JOB_TYPE_VERTEX: |
| 1556 | case MALI_JOB_TYPE_COMPUTE: |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1557 | if (bifrost) { |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1558 | if (h.type == MALI_JOB_TYPE_TILER) |
| 1559 | pandecode_tiler_job_bfr(&h, mem, payload_ptr, job_no, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1560 | else |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1561 | pandecode_vertex_job_bfr(&h, mem, payload_ptr, job_no, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1562 | } else |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1563 | pandecode_vertex_or_tiler_job_mdg(&h, mem, payload_ptr, job_no, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1564 | |
| 1565 | break; |
| 1566 | |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1567 | case MALI_JOB_TYPE_FRAGMENT: |
Tomeu Vizoso | 697f02c | 2019-11-12 12:15:02 +0100 | [diff] [blame] | 1568 | pandecode_fragment_job(mem, payload_ptr, job_no, bifrost, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1569 | break; |
| 1570 | |
| 1571 | default: |
| 1572 | break; |
| 1573 | } |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame^] | 1574 | } while ((jc_gpu_va = next_job)); |
Icecream95 | ef67218 | 2020-06-22 22:49:53 +1200 | [diff] [blame] | 1575 | |
| 1576 | pandecode_map_read_write(); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1577 | } |