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 | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 186 | struct pandecode_flag_info { |
| 187 | u64 flag; |
| 188 | const char *name; |
| 189 | }; |
| 190 | |
| 191 | static void |
| 192 | pandecode_log_decoded_flags(const struct pandecode_flag_info *flag_info, |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 193 | u64 flags) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 194 | { |
| 195 | bool decodable_flags_found = false; |
| 196 | |
| 197 | for (int i = 0; flag_info[i].name; i++) { |
| 198 | if ((flags & flag_info[i].flag) != flag_info[i].flag) |
| 199 | continue; |
| 200 | |
| 201 | if (!decodable_flags_found) { |
| 202 | decodable_flags_found = true; |
| 203 | } else { |
| 204 | pandecode_log_cont(" | "); |
| 205 | } |
| 206 | |
| 207 | pandecode_log_cont("%s", flag_info[i].name); |
| 208 | |
| 209 | flags &= ~flag_info[i].flag; |
| 210 | } |
| 211 | |
| 212 | if (decodable_flags_found) { |
| 213 | if (flags) |
| 214 | pandecode_log_cont(" | 0x%" PRIx64, flags); |
| 215 | } else { |
| 216 | pandecode_log_cont("0x%" PRIx64, flags); |
| 217 | } |
| 218 | } |
| 219 | |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 220 | #define FLAG_INFO(flag) { MALI_MFBD_FORMAT_##flag, "MALI_MFBD_FORMAT_" #flag } |
| 221 | static const struct pandecode_flag_info mfbd_fmt_flag_info[] = { |
Alyssa Rosenzweig | 31a4ef8 | 2019-06-17 16:01:24 -0700 | [diff] [blame] | 222 | FLAG_INFO(SRGB), |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 223 | {} |
| 224 | }; |
| 225 | #undef FLAG_INFO |
| 226 | |
Icecream95 | 9ac106d | 2020-06-02 14:13:03 +1200 | [diff] [blame] | 227 | #define FLAG_INFO(flag) { MALI_AFBC_##flag, "MALI_AFBC_" #flag } |
| 228 | static const struct pandecode_flag_info afbc_fmt_flag_info[] = { |
| 229 | FLAG_INFO(YTR), |
| 230 | {} |
| 231 | }; |
| 232 | #undef FLAG_INFO |
| 233 | |
Alyssa Rosenzweig | 587ad37 | 2019-03-09 00:45:23 +0000 | [diff] [blame] | 234 | #define FLAG_INFO(flag) { MALI_EXTRA_##flag, "MALI_EXTRA_" #flag } |
Alyssa Rosenzweig | 6bd9c4d | 2020-01-10 13:12:35 -0500 | [diff] [blame] | 235 | static const struct pandecode_flag_info mfbd_extra_flag_hi_info[] = { |
Alyssa Rosenzweig | 587ad37 | 2019-03-09 00:45:23 +0000 | [diff] [blame] | 236 | FLAG_INFO(PRESENT), |
Alyssa Rosenzweig | 6bd9c4d | 2020-01-10 13:12:35 -0500 | [diff] [blame] | 237 | {} |
| 238 | }; |
| 239 | #undef FLAG_INFO |
| 240 | |
| 241 | #define FLAG_INFO(flag) { MALI_EXTRA_##flag, "MALI_EXTRA_" #flag } |
| 242 | static const struct pandecode_flag_info mfbd_extra_flag_lo_info[] = { |
Alyssa Rosenzweig | 587ad37 | 2019-03-09 00:45:23 +0000 | [diff] [blame] | 243 | FLAG_INFO(ZS), |
| 244 | {} |
| 245 | }; |
| 246 | #undef FLAG_INFO |
| 247 | |
Alyssa Rosenzweig | ac68946 | 2019-06-14 11:14:01 -0700 | [diff] [blame] | 248 | #define FLAG_INFO(flag) { MALI_MFBD_##flag, "MALI_MFBD_" #flag } |
| 249 | static const struct pandecode_flag_info mfbd_flag_info [] = { |
| 250 | FLAG_INFO(DEPTH_WRITE), |
| 251 | FLAG_INFO(EXTRA), |
| 252 | {} |
| 253 | }; |
| 254 | #undef FLAG_INFO |
| 255 | |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 256 | /* Midgard's tiler descriptor is embedded within the |
| 257 | * larger FBD */ |
| 258 | |
| 259 | static void |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 260 | pandecode_midgard_tiler_descriptor( |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 261 | const struct mali_midgard_tiler_packed *tp, |
| 262 | const struct mali_midgard_tiler_weights_packed *wp, |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 263 | unsigned width, |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 264 | unsigned height, |
Alyssa Rosenzweig | 9fb0904 | 2019-11-27 08:31:16 -0500 | [diff] [blame] | 265 | bool is_fragment, |
| 266 | bool has_hierarchy) |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 267 | { |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 268 | pan_unpack(tp, MIDGARD_TILER, t); |
| 269 | DUMP_UNPACKED(MIDGARD_TILER, t, "Tiler:\n"); |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 270 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 271 | MEMORY_PROP_DIR(t, polygon_list); |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 272 | |
Alyssa Rosenzweig | 52101e4 | 2019-08-19 10:38:25 -0700 | [diff] [blame] | 273 | /* The body is offset from the base of the polygon list */ |
Alyssa Rosenzweig | b010a6d | 2020-04-06 20:31:32 -0400 | [diff] [blame] | 274 | //assert(t->polygon_list_body > t->polygon_list); |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 275 | unsigned body_offset = t.polygon_list_body - t.polygon_list; |
Alyssa Rosenzweig | 52101e4 | 2019-08-19 10:38:25 -0700 | [diff] [blame] | 276 | |
| 277 | /* It needs to fit inside the reported size */ |
Alyssa Rosenzweig | b010a6d | 2020-04-06 20:31:32 -0400 | [diff] [blame] | 278 | //assert(t->polygon_list_size >= body_offset); |
Alyssa Rosenzweig | 52101e4 | 2019-08-19 10:38:25 -0700 | [diff] [blame] | 279 | |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 280 | /* Now that we've sanity checked, we'll try to calculate the sizes |
| 281 | * ourselves for comparison */ |
| 282 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 283 | unsigned ref_header = panfrost_tiler_header_size(width, height, t.hierarchy_mask, has_hierarchy); |
| 284 | 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] | 285 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 286 | if (!((ref_header == body_offset) && (ref_size == t.polygon_list_size))) { |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 287 | pandecode_msg("XXX: bad polygon list size (expected %d / 0x%x)\n", |
| 288 | ref_header, ref_size); |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 289 | pandecode_prop("polygon_list_size = 0x%x", t.polygon_list_size); |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 290 | pandecode_msg("body offset %d\n", body_offset); |
| 291 | } |
Alyssa Rosenzweig | 52101e4 | 2019-08-19 10:38:25 -0700 | [diff] [blame] | 292 | |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 293 | /* The tiler heap has a start and end specified -- it should be |
| 294 | * identical to what we have in the BO. The exception is if tiling is |
| 295 | * disabled. */ |
Alyssa Rosenzweig | 13d0797 | 2019-08-19 10:56:23 -0700 | [diff] [blame] | 296 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 297 | MEMORY_PROP_DIR(t, heap_start); |
| 298 | assert(t.heap_end >= t.heap_start); |
Alyssa Rosenzweig | 13d0797 | 2019-08-19 10:56:23 -0700 | [diff] [blame] | 299 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 300 | unsigned heap_size = t.heap_end - t.heap_start; |
Alyssa Rosenzweig | 13d0797 | 2019-08-19 10:56:23 -0700 | [diff] [blame] | 301 | |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 302 | /* Tiling is enabled with a special flag */ |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 303 | unsigned hierarchy_mask = t.hierarchy_mask & MALI_MIDGARD_TILER_HIERARCHY_MASK; |
| 304 | unsigned tiler_flags = t.hierarchy_mask ^ hierarchy_mask; |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 305 | |
| 306 | bool tiling_enabled = hierarchy_mask; |
| 307 | |
| 308 | if (tiling_enabled) { |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 309 | /* We should also have no other flags */ |
| 310 | if (tiler_flags) |
| 311 | pandecode_msg("XXX: unexpected tiler %X\n", tiler_flags); |
| 312 | } else { |
| 313 | /* When tiling is disabled, we should have that flag and no others */ |
| 314 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 315 | if (tiler_flags != MALI_MIDGARD_TILER_DISABLED) { |
| 316 | 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] | 317 | tiler_flags); |
| 318 | } |
| 319 | |
| 320 | /* We should also have an empty heap */ |
| 321 | if (heap_size) { |
| 322 | pandecode_msg("XXX: tiler heap size %d given, expected empty\n", |
| 323 | heap_size); |
| 324 | } |
| 325 | |
| 326 | /* Disabled tiling is used only for clear-only jobs, which are |
| 327 | * purely FRAGMENT, so we should never see this for |
| 328 | * non-FRAGMENT descriptors. */ |
| 329 | |
| 330 | if (!is_fragment) |
| 331 | pandecode_msg("XXX: tiler disabled for non-FRAGMENT job\n"); |
| 332 | } |
| 333 | |
| 334 | /* We've never seen weights used in practice, but we know from the |
| 335 | * kernel these fields is there */ |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 336 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 337 | pan_unpack(wp, MIDGARD_TILER_WEIGHTS, w); |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 338 | bool nonzero_weights = false; |
| 339 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 340 | nonzero_weights |= w.weight0 != 0x0; |
| 341 | nonzero_weights |= w.weight1 != 0x0; |
| 342 | nonzero_weights |= w.weight2 != 0x0; |
| 343 | nonzero_weights |= w.weight3 != 0x0; |
| 344 | nonzero_weights |= w.weight4 != 0x0; |
| 345 | nonzero_weights |= w.weight5 != 0x0; |
| 346 | nonzero_weights |= w.weight6 != 0x0; |
| 347 | nonzero_weights |= w.weight7 != 0x0; |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 348 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 349 | if (nonzero_weights) |
| 350 | DUMP_UNPACKED(MIDGARD_TILER_WEIGHTS, w, "Tiler Weights:\n"); |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 351 | } |
| 352 | |
Alyssa Rosenzweig | 3044a37 | 2020-02-28 07:25:25 -0500 | [diff] [blame] | 353 | /* TODO: The Bifrost tiler is not understood at all yet */ |
| 354 | |
| 355 | static void |
Tomeu Vizoso | 46e4246 | 2020-04-08 15:58:42 +0200 | [diff] [blame] | 356 | pandecode_bifrost_tiler_descriptor(const struct mali_framebuffer *fb) |
Alyssa Rosenzweig | 3044a37 | 2020-02-28 07:25:25 -0500 | [diff] [blame] | 357 | { |
| 358 | pandecode_log(".tiler = {\n"); |
| 359 | pandecode_indent++; |
| 360 | |
Tomeu Vizoso | 46e4246 | 2020-04-08 15:58:42 +0200 | [diff] [blame] | 361 | MEMORY_PROP(fb, tiler_meta); |
Alyssa Rosenzweig | 3044a37 | 2020-02-28 07:25:25 -0500 | [diff] [blame] | 362 | |
Tomeu Vizoso | 46e4246 | 2020-04-08 15:58:42 +0200 | [diff] [blame] | 363 | for (int i = 0; i < 16; i++) { |
| 364 | if (fb->zeros[i] != 0) { |
| 365 | pandecode_msg("XXX: tiler descriptor zero %d tripped, value %x\n", |
| 366 | i, fb->zeros[i]); |
| 367 | } |
Alyssa Rosenzweig | 3044a37 | 2020-02-28 07:25:25 -0500 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | pandecode_log("},\n"); |
| 371 | |
| 372 | pandecode_indent--; |
| 373 | pandecode_log("}\n"); |
| 374 | |
| 375 | } |
| 376 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 377 | /* Information about the framebuffer passed back for |
| 378 | * additional analysis */ |
| 379 | |
| 380 | struct pandecode_fbd { |
| 381 | unsigned width; |
| 382 | unsigned height; |
| 383 | unsigned rt_count; |
| 384 | bool has_extra; |
| 385 | }; |
| 386 | |
| 387 | static struct pandecode_fbd |
Tomeu Vizoso | 697f02c | 2019-11-12 12:15:02 +0100 | [diff] [blame] | 388 | 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] | 389 | { |
| 390 | 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] | 391 | const void *PANDECODE_PTR_VAR(s, mem, (mali_ptr) gpu_va); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 392 | |
Alyssa Rosenzweig | d6d6d63 | 2019-08-30 17:00:09 -0700 | [diff] [blame] | 393 | struct pandecode_fbd info = { |
| 394 | .has_extra = false, |
| 395 | .rt_count = 1 |
| 396 | }; |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 397 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 398 | pandecode_log("Single-Target Framebuffer:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 399 | pandecode_indent++; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 400 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 401 | DUMP_SECTION(SINGLE_TARGET_FRAMEBUFFER, LOCAL_STORAGE, s, "Local Storage:\n"); |
| 402 | pan_section_unpack(s, SINGLE_TARGET_FRAMEBUFFER, PARAMETERS, p); |
| 403 | DUMP_UNPACKED(SINGLE_TARGET_FRAMEBUFFER_PARAMETERS, p, "Parameters:\n"); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 404 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 405 | const void *t = pan_section_ptr(s, SINGLE_TARGET_FRAMEBUFFER, TILER); |
| 406 | const void *w = pan_section_ptr(s, SINGLE_TARGET_FRAMEBUFFER, TILER_WEIGHTS); |
Alyssa Rosenzweig | 9fb0904 | 2019-11-27 08:31:16 -0500 | [diff] [blame] | 407 | |
| 408 | bool has_hierarchy = !(gpu_id == 0x0720 || gpu_id == 0x0820 || gpu_id == 0x0830); |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 409 | 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] | 410 | |
| 411 | pandecode_indent--; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 412 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 413 | /* Dummy unpack of the padding section to make sure all words are 0. |
| 414 | * No need to call print here since the section is supposed to be empty. |
| 415 | */ |
| 416 | pan_section_unpack(s, SINGLE_TARGET_FRAMEBUFFER, PADDING_1, padding1); |
| 417 | pan_section_unpack(s, SINGLE_TARGET_FRAMEBUFFER, PADDING_2, padding2); |
| 418 | pandecode_log("\n"); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 419 | |
| 420 | return info; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | static void |
Alyssa Rosenzweig | 0aa5d89 | 2019-06-19 08:41:51 -0700 | [diff] [blame] | 424 | pandecode_compute_fbd(uint64_t gpu_va, int job_no) |
| 425 | { |
| 426 | 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] | 427 | const struct mali_local_storage_packed *PANDECODE_PTR_VAR(s, mem, (mali_ptr) gpu_va); |
| 428 | DUMP_CL(LOCAL_STORAGE, s, "Local Storage:\n"); |
Alyssa Rosenzweig | 0aa5d89 | 2019-06-19 08:41:51 -0700 | [diff] [blame] | 429 | } |
| 430 | |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 431 | /* Extracts the number of components associated with a Mali format */ |
| 432 | |
| 433 | static unsigned |
| 434 | pandecode_format_component_count(enum mali_format fmt) |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 435 | { |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 436 | /* Mask out the format class */ |
| 437 | unsigned top = fmt & 0b11100000; |
| 438 | |
| 439 | switch (top) { |
| 440 | case MALI_FORMAT_SNORM: |
| 441 | case MALI_FORMAT_UINT: |
| 442 | case MALI_FORMAT_UNORM: |
| 443 | case MALI_FORMAT_SINT: |
| 444 | return ((fmt >> 3) & 3) + 1; |
| 445 | default: |
| 446 | /* TODO: Validate */ |
| 447 | return 4; |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | /* Extracts a mask of accessed components from a 12-bit Mali swizzle */ |
| 452 | |
| 453 | static unsigned |
| 454 | pandecode_access_mask_from_channel_swizzle(unsigned swizzle) |
| 455 | { |
| 456 | unsigned mask = 0; |
Alyssa Rosenzweig | cdc3276 | 2020-08-12 16:46:07 -0400 | [diff] [blame] | 457 | assert(MALI_CHANNEL_R == 0); |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 458 | |
| 459 | for (unsigned c = 0; c < 4; ++c) { |
| 460 | enum mali_channel chan = (swizzle >> (3*c)) & 0x7; |
| 461 | |
Alyssa Rosenzweig | cdc3276 | 2020-08-12 16:46:07 -0400 | [diff] [blame] | 462 | if (chan <= MALI_CHANNEL_A) |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 463 | mask |= (1 << chan); |
| 464 | } |
| 465 | |
| 466 | return mask; |
| 467 | } |
| 468 | |
| 469 | /* Validates that a (format, swizzle) pair is valid, in the sense that the |
| 470 | * swizzle doesn't access any components that are undefined in the format. |
| 471 | * Returns whether the swizzle is trivial (doesn't do any swizzling) and can be |
| 472 | * omitted */ |
| 473 | |
| 474 | static bool |
| 475 | pandecode_validate_format_swizzle(enum mali_format fmt, unsigned swizzle) |
| 476 | { |
| 477 | unsigned nr_comp = pandecode_format_component_count(fmt); |
| 478 | unsigned access_mask = pandecode_access_mask_from_channel_swizzle(swizzle); |
| 479 | unsigned valid_mask = (1 << nr_comp) - 1; |
| 480 | unsigned invalid_mask = ~valid_mask; |
| 481 | |
| 482 | if (access_mask & invalid_mask) { |
| 483 | pandecode_msg("XXX: invalid components accessed\n"); |
| 484 | return false; |
| 485 | } |
| 486 | |
| 487 | /* Check for the default non-swizzling swizzle so we can suppress |
| 488 | * useless printing for the defaults */ |
| 489 | |
| 490 | unsigned default_swizzles[4] = { |
Alyssa Rosenzweig | cdc3276 | 2020-08-12 16:46:07 -0400 | [diff] [blame] | 491 | MALI_CHANNEL_R | (MALI_CHANNEL_0 << 3) | (MALI_CHANNEL_0 << 6) | (MALI_CHANNEL_1 << 9), |
| 492 | MALI_CHANNEL_R | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_0 << 6) | (MALI_CHANNEL_1 << 9), |
| 493 | MALI_CHANNEL_R | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_B << 6) | (MALI_CHANNEL_1 << 9), |
| 494 | 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] | 495 | }; |
| 496 | |
| 497 | return (swizzle == default_swizzles[nr_comp - 1]); |
| 498 | } |
| 499 | |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 500 | static void |
| 501 | pandecode_swizzle(unsigned swizzle, enum mali_format format) |
| 502 | { |
| 503 | /* First, do some validation */ |
| 504 | bool trivial_swizzle = pandecode_validate_format_swizzle( |
| 505 | format, swizzle); |
| 506 | |
| 507 | if (trivial_swizzle) |
| 508 | return; |
| 509 | |
| 510 | /* Next, print the swizzle */ |
| 511 | pandecode_log_cont("."); |
| 512 | |
| 513 | static const char components[] = "rgba01"; |
| 514 | |
| 515 | for (unsigned c = 0; c < 4; ++c) { |
| 516 | enum mali_channel chan = (swizzle >> (3 * c)) & 0x7; |
| 517 | |
Alyssa Rosenzweig | cdc3276 | 2020-08-12 16:46:07 -0400 | [diff] [blame] | 518 | if (chan > MALI_CHANNEL_1) { |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 519 | pandecode_log("XXX: invalid swizzle channel %d\n", chan); |
| 520 | continue; |
| 521 | } |
| 522 | pandecode_log_cont("%c", components[chan]); |
| 523 | } |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | static void |
| 527 | pandecode_rt_format(struct mali_rt_format format) |
| 528 | { |
| 529 | pandecode_log(".format = {\n"); |
| 530 | pandecode_indent++; |
| 531 | |
| 532 | pandecode_prop("unk1 = 0x%" PRIx32, format.unk1); |
| 533 | pandecode_prop("unk2 = 0x%" PRIx32, format.unk2); |
Alyssa Rosenzweig | d507951 | 2019-06-17 15:53:09 -0700 | [diff] [blame] | 534 | pandecode_prop("unk3 = 0x%" PRIx32, format.unk3); |
Tomeu Vizoso | 28902ba | 2020-04-24 11:30:03 +0200 | [diff] [blame] | 535 | pandecode_prop("unk4 = 0x%" PRIx32, format.unk4); |
Alyssa Rosenzweig | d507951 | 2019-06-17 15:53:09 -0700 | [diff] [blame] | 536 | |
Alyssa Rosenzweig | c9bdba2 | 2020-08-11 21:00:47 -0400 | [diff] [blame] | 537 | pandecode_prop("block = %s", mali_block_format_as_str(format.block)); |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 538 | |
Alyssa Rosenzweig | e09392f | 2019-08-20 14:34:09 -0700 | [diff] [blame] | 539 | /* TODO: Map formats so we can check swizzles and print nicely */ |
| 540 | pandecode_log("swizzle"); |
| 541 | pandecode_swizzle(format.swizzle, MALI_RGBA8_UNORM); |
| 542 | pandecode_log_cont(",\n"); |
| 543 | |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 544 | pandecode_prop("nr_channels = MALI_POSITIVE(%d)", |
Alyssa Rosenzweig | 4ccd42e | 2019-12-27 12:16:09 -0500 | [diff] [blame] | 545 | (format.nr_channels + 1)); |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 546 | |
| 547 | pandecode_log(".flags = "); |
| 548 | pandecode_log_decoded_flags(mfbd_fmt_flag_info, format.flags); |
| 549 | pandecode_log_cont(",\n"); |
| 550 | |
Alyssa Rosenzweig | 99d17fb | 2020-08-11 21:04:01 -0400 | [diff] [blame] | 551 | pandecode_prop("msaa = %s", mali_msaa_as_str(format.msaa)); |
Alyssa Rosenzweig | 2c47993 | 2020-07-21 18:51:07 -0400 | [diff] [blame] | 552 | |
Alyssa Rosenzweig | e49204c | 2019-08-20 11:11:46 -0700 | [diff] [blame] | 553 | /* In theory, the no_preload bit can be cleared to enable MFBD preload, |
| 554 | * which is a faster hardware-based alternative to the wallpaper method |
| 555 | * to preserve framebuffer contents across frames. In practice, MFBD |
| 556 | * preload is buggy on Midgard, and so this is a chicken bit. If this |
| 557 | * bit isn't set, most likely something broke unrelated to preload */ |
| 558 | |
| 559 | if (!format.no_preload) { |
| 560 | pandecode_msg("XXX: buggy MFBD preload enabled - chicken bit should be clear\n"); |
| 561 | pandecode_prop("no_preload = 0x%" PRIx32, format.no_preload); |
| 562 | } |
Alyssa Rosenzweig | b78e04c | 2019-08-14 16:01:38 -0700 | [diff] [blame] | 563 | |
| 564 | if (format.zero) |
| 565 | pandecode_prop("zero = 0x%" PRIx32, format.zero); |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 566 | |
| 567 | pandecode_indent--; |
| 568 | pandecode_log("},\n"); |
| 569 | } |
| 570 | |
| 571 | static void |
Alyssa Rosenzweig | 6d9ee3e | 2020-02-10 08:51:37 -0500 | [diff] [blame] | 572 | pandecode_render_target(uint64_t gpu_va, unsigned job_no, const struct mali_framebuffer *fb) |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 573 | { |
Alyssa Rosenzweig | 6d9ee3e | 2020-02-10 08:51:37 -0500 | [diff] [blame] | 574 | pandecode_log("struct mali_render_target rts_list_%"PRIx64"_%d[] = {\n", gpu_va, job_no); |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 575 | pandecode_indent++; |
| 576 | |
Alyssa Rosenzweig | 4ccd42e | 2019-12-27 12:16:09 -0500 | [diff] [blame] | 577 | for (int i = 0; i < (fb->rt_count_1 + 1); i++) { |
Alyssa Rosenzweig | 6d9ee3e | 2020-02-10 08:51:37 -0500 | [diff] [blame] | 578 | mali_ptr rt_va = gpu_va + i * sizeof(struct mali_render_target); |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 579 | struct pandecode_mapped_memory *mem = |
| 580 | pandecode_find_mapped_gpu_mem_containing(rt_va); |
Alyssa Rosenzweig | 6d9ee3e | 2020-02-10 08:51:37 -0500 | [diff] [blame] | 581 | const struct mali_render_target *PANDECODE_PTR_VAR(rt, mem, (mali_ptr) rt_va); |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 582 | |
| 583 | pandecode_log("{\n"); |
| 584 | pandecode_indent++; |
| 585 | |
| 586 | pandecode_rt_format(rt->format); |
| 587 | |
Alyssa Rosenzweig | c9bdba2 | 2020-08-11 21:00:47 -0400 | [diff] [blame] | 588 | if (rt->format.block == MALI_BLOCK_FORMAT_AFBC) { |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 589 | pandecode_log(".afbc = {\n"); |
| 590 | pandecode_indent++; |
| 591 | |
| 592 | char *a = pointer_as_memory_reference(rt->afbc.metadata); |
| 593 | pandecode_prop("metadata = %s", a); |
| 594 | free(a); |
| 595 | |
| 596 | pandecode_prop("stride = %d", rt->afbc.stride); |
Icecream95 | 9ac106d | 2020-06-02 14:13:03 +1200 | [diff] [blame] | 597 | |
| 598 | pandecode_log(".flags = "); |
| 599 | pandecode_log_decoded_flags(afbc_fmt_flag_info, rt->afbc.flags); |
| 600 | pandecode_log_cont(",\n"); |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 601 | |
| 602 | pandecode_indent--; |
| 603 | pandecode_log("},\n"); |
Icecream95 | 9ac106d | 2020-06-02 14:13:03 +1200 | [diff] [blame] | 604 | } else if (rt->afbc.metadata || rt->afbc.stride || rt->afbc.flags) { |
Alyssa Rosenzweig | c9b6233 | 2019-08-20 11:06:07 -0700 | [diff] [blame] | 605 | pandecode_msg("XXX: AFBC disabled but AFBC field set (0x%lX, 0x%x, 0x%x)\n", |
| 606 | rt->afbc.metadata, |
| 607 | rt->afbc.stride, |
Icecream95 | 9ac106d | 2020-06-02 14:13:03 +1200 | [diff] [blame] | 608 | rt->afbc.flags); |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | MEMORY_PROP(rt, framebuffer); |
| 612 | pandecode_prop("framebuffer_stride = %d", rt->framebuffer_stride); |
| 613 | |
Alyssa Rosenzweig | 3720458 | 2020-06-30 16:21:18 -0400 | [diff] [blame] | 614 | if (rt->layer_stride) |
| 615 | pandecode_prop("layer_stride = %d", rt->layer_stride); |
| 616 | |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 617 | if (rt->clear_color_1 | rt->clear_color_2 | rt->clear_color_3 | rt->clear_color_4) { |
| 618 | pandecode_prop("clear_color_1 = 0x%" PRIx32, rt->clear_color_1); |
| 619 | pandecode_prop("clear_color_2 = 0x%" PRIx32, rt->clear_color_2); |
| 620 | pandecode_prop("clear_color_3 = 0x%" PRIx32, rt->clear_color_3); |
| 621 | pandecode_prop("clear_color_4 = 0x%" PRIx32, rt->clear_color_4); |
| 622 | } |
| 623 | |
Alyssa Rosenzweig | 3720458 | 2020-06-30 16:21:18 -0400 | [diff] [blame] | 624 | if (rt->zero1 || rt->zero2) { |
Alyssa Rosenzweig | 89c5370 | 2019-08-20 11:18:46 -0700 | [diff] [blame] | 625 | pandecode_msg("XXX: render target zeros tripped\n"); |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 626 | pandecode_prop("zero1 = 0x%" PRIx64, rt->zero1); |
| 627 | pandecode_prop("zero2 = 0x%" PRIx32, rt->zero2); |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | pandecode_indent--; |
| 631 | pandecode_log("},\n"); |
| 632 | } |
| 633 | |
| 634 | pandecode_indent--; |
| 635 | pandecode_log("};\n"); |
| 636 | } |
| 637 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 638 | static struct pandecode_fbd |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 639 | pandecode_mfbd_bfr(uint64_t gpu_va, int job_no, bool is_fragment, bool is_compute, bool is_bifrost) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 640 | { |
| 641 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); |
Alyssa Rosenzweig | 6d9ee3e | 2020-02-10 08:51:37 -0500 | [diff] [blame] | 642 | const struct mali_framebuffer *PANDECODE_PTR_VAR(fb, mem, (mali_ptr) gpu_va); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 643 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 644 | struct pandecode_fbd info; |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 645 | |
| 646 | if (is_bifrost && fb->msaa.sample_locations) { |
| 647 | /* The blob stores all possible sample locations in a single buffer |
| 648 | * allocated on startup, and just switches the pointer when switching |
| 649 | * MSAA state. For now, we just put the data into the cmdstream, but we |
| 650 | * should do something like what the blob does with a real driver. |
| 651 | * |
| 652 | * There seem to be 32 slots for sample locations, followed by another |
| 653 | * 16. The second 16 is just the center location followed by 15 zeros |
| 654 | * in all the cases I've identified (maybe shader vs. depth/color |
| 655 | * samples?). |
| 656 | */ |
| 657 | |
| 658 | struct pandecode_mapped_memory *smem = pandecode_find_mapped_gpu_mem_containing(fb->msaa.sample_locations); |
| 659 | |
| 660 | const u16 *PANDECODE_PTR_VAR(samples, smem, fb->msaa.sample_locations); |
| 661 | |
| 662 | pandecode_log("uint16_t sample_locations_%d[] = {\n", job_no); |
| 663 | pandecode_indent++; |
| 664 | |
| 665 | for (int i = 0; i < 32 + 16; i++) { |
| 666 | pandecode_log("%d, %d,\n", samples[2 * i], samples[2 * i + 1]); |
| 667 | } |
| 668 | |
| 669 | pandecode_indent--; |
| 670 | pandecode_log("};\n"); |
| 671 | } |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 672 | |
Alyssa Rosenzweig | 6d9ee3e | 2020-02-10 08:51:37 -0500 | [diff] [blame] | 673 | pandecode_log("struct mali_framebuffer framebuffer_%"PRIx64"_%d = {\n", gpu_va, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 674 | pandecode_indent++; |
| 675 | |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 676 | if (is_bifrost) { |
| 677 | pandecode_log(".msaa = {\n"); |
| 678 | pandecode_indent++; |
| 679 | |
| 680 | if (fb->msaa.sample_locations) |
| 681 | pandecode_prop("sample_locations = sample_locations_%d", job_no); |
| 682 | else |
| 683 | pandecode_msg("XXX: sample_locations missing\n"); |
| 684 | |
| 685 | if (fb->msaa.zero1 || fb->msaa.zero2 || fb->msaa.zero4) { |
| 686 | pandecode_msg("XXX: multisampling zero tripped\n"); |
| 687 | pandecode_prop("zero1 = %" PRIx64, fb->msaa.zero1); |
| 688 | pandecode_prop("zero2 = %" PRIx64, fb->msaa.zero2); |
| 689 | pandecode_prop("zero4 = %" PRIx64, fb->msaa.zero4); |
| 690 | } |
| 691 | |
| 692 | pandecode_indent--; |
| 693 | pandecode_log("},\n"); |
| 694 | } else { |
Boris Brezillon | 3a06fc3 | 2020-09-03 09:18:09 +0200 | [diff] [blame] | 695 | struct mali_local_storage_packed ls = fb->shared_memory; |
| 696 | DUMP_CL(LOCAL_STORAGE, &ls, "Local Storage:\n"); |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 697 | } |
Alyssa Rosenzweig | 85e745f | 2019-06-12 09:33:06 -0700 | [diff] [blame] | 698 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 699 | info.width = fb->width1 + 1; |
| 700 | info.height = fb->height1 + 1; |
| 701 | info.rt_count = fb->rt_count_1 + 1; |
| 702 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 703 | pandecode_prop("width1 = MALI_POSITIVE(%d)", fb->width1 + 1); |
| 704 | pandecode_prop("height1 = MALI_POSITIVE(%d)", fb->height1 + 1); |
| 705 | pandecode_prop("width2 = MALI_POSITIVE(%d)", fb->width2 + 1); |
| 706 | pandecode_prop("height2 = MALI_POSITIVE(%d)", fb->height2 + 1); |
| 707 | |
| 708 | pandecode_prop("unk1 = 0x%x", fb->unk1); |
| 709 | pandecode_prop("unk2 = 0x%x", fb->unk2); |
| 710 | pandecode_prop("rt_count_1 = MALI_POSITIVE(%d)", fb->rt_count_1 + 1); |
| 711 | pandecode_prop("rt_count_2 = %d", fb->rt_count_2); |
| 712 | |
Alyssa Rosenzweig | ac68946 | 2019-06-14 11:14:01 -0700 | [diff] [blame] | 713 | pandecode_log(".mfbd_flags = "); |
| 714 | pandecode_log_decoded_flags(mfbd_flag_info, fb->mfbd_flags); |
| 715 | pandecode_log_cont(",\n"); |
| 716 | |
Alyssa Rosenzweig | 3752f76 | 2019-08-20 11:25:29 -0700 | [diff] [blame] | 717 | if (fb->clear_stencil) |
| 718 | pandecode_prop("clear_stencil = 0x%x", fb->clear_stencil); |
| 719 | |
| 720 | if (fb->clear_depth) |
| 721 | pandecode_prop("clear_depth = %f", fb->clear_depth); |
| 722 | |
Alyssa Rosenzweig | 3993969 | 2020-01-22 08:51:19 -0500 | [diff] [blame] | 723 | if (!is_compute) |
Alyssa Rosenzweig | 3044a37 | 2020-02-28 07:25:25 -0500 | [diff] [blame] | 724 | if (is_bifrost) |
Tomeu Vizoso | 46e4246 | 2020-04-08 15:58:42 +0200 | [diff] [blame] | 725 | pandecode_bifrost_tiler_descriptor(fb); |
Alyssa Rosenzweig | c2c8b1a | 2020-05-26 18:10:39 -0400 | [diff] [blame] | 726 | else { |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 727 | const struct mali_midgard_tiler_packed t = fb->tiler; |
| 728 | const struct mali_midgard_tiler_weights_packed w = fb->tiler_weights; |
| 729 | pandecode_midgard_tiler_descriptor(&t, &w, fb->width1 + 1, fb->height1 + 1, is_fragment, true); |
Alyssa Rosenzweig | c2c8b1a | 2020-05-26 18:10:39 -0400 | [diff] [blame] | 730 | } |
Alyssa Rosenzweig | 3993969 | 2020-01-22 08:51:19 -0500 | [diff] [blame] | 731 | else |
| 732 | pandecode_msg("XXX: skipping compute MFBD, fixme\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 733 | |
Alyssa Rosenzweig | 85e745f | 2019-06-12 09:33:06 -0700 | [diff] [blame] | 734 | if (fb->zero3 || fb->zero4) { |
Alyssa Rosenzweig | 89c5370 | 2019-08-20 11:18:46 -0700 | [diff] [blame] | 735 | pandecode_msg("XXX: framebuffer zeros tripped\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 736 | pandecode_prop("zero3 = 0x%" PRIx32, fb->zero3); |
| 737 | pandecode_prop("zero4 = 0x%" PRIx32, fb->zero4); |
Alyssa Rosenzweig | 85e745f | 2019-06-12 09:33:06 -0700 | [diff] [blame] | 738 | } |
| 739 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 740 | pandecode_indent--; |
| 741 | pandecode_log("};\n"); |
| 742 | |
Alyssa Rosenzweig | 6d9ee3e | 2020-02-10 08:51:37 -0500 | [diff] [blame] | 743 | gpu_va += sizeof(struct mali_framebuffer); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 744 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 745 | info.has_extra = (fb->mfbd_flags & MALI_MFBD_EXTRA) && is_fragment; |
| 746 | |
| 747 | if (info.has_extra) { |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 748 | mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); |
Alyssa Rosenzweig | 6d9ee3e | 2020-02-10 08:51:37 -0500 | [diff] [blame] | 749 | const struct mali_framebuffer_extra *PANDECODE_PTR_VAR(fbx, mem, (mali_ptr) gpu_va); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 750 | |
Alyssa Rosenzweig | 6d9ee3e | 2020-02-10 08:51:37 -0500 | [diff] [blame] | 751 | pandecode_log("struct mali_framebuffer_extra fb_extra_%"PRIx64"_%d = {\n", gpu_va, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 752 | pandecode_indent++; |
| 753 | |
| 754 | MEMORY_PROP(fbx, checksum); |
| 755 | |
| 756 | if (fbx->checksum_stride) |
| 757 | pandecode_prop("checksum_stride = %d", fbx->checksum_stride); |
| 758 | |
Alyssa Rosenzweig | 6bd9c4d | 2020-01-10 13:12:35 -0500 | [diff] [blame] | 759 | pandecode_log(".flags_hi = "); |
Alyssa Rosenzweig | 7e53cce | 2020-05-04 12:48:34 -0400 | [diff] [blame] | 760 | pandecode_log_decoded_flags(mfbd_extra_flag_hi_info, fbx->flags_hi); |
Alyssa Rosenzweig | 587ad37 | 2019-03-09 00:45:23 +0000 | [diff] [blame] | 761 | pandecode_log_cont(",\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 762 | |
Alyssa Rosenzweig | 6bd9c4d | 2020-01-10 13:12:35 -0500 | [diff] [blame] | 763 | pandecode_log(".flags_lo = "); |
| 764 | pandecode_log_decoded_flags(mfbd_extra_flag_lo_info, fbx->flags_lo); |
| 765 | pandecode_log_cont(",\n"); |
| 766 | |
Alyssa Rosenzweig | c9bdba2 | 2020-08-11 21:00:47 -0400 | [diff] [blame] | 767 | pandecode_prop("zs_block = %s", mali_block_format_as_str(fbx->zs_block)); |
Alyssa Rosenzweig | e061bf0 | 2020-07-15 11:57:35 -0400 | [diff] [blame] | 768 | pandecode_prop("zs_samples = MALI_POSITIVE(%u)", fbx->zs_samples + 1); |
Alyssa Rosenzweig | 6bd9c4d | 2020-01-10 13:12:35 -0500 | [diff] [blame] | 769 | |
Alyssa Rosenzweig | c9bdba2 | 2020-08-11 21:00:47 -0400 | [diff] [blame] | 770 | if (fbx->zs_block == MALI_BLOCK_FORMAT_AFBC) { |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 771 | pandecode_log(".ds_afbc = {\n"); |
| 772 | pandecode_indent++; |
| 773 | |
Alyssa Rosenzweig | 0c1874a | 2019-07-12 08:47:35 -0700 | [diff] [blame] | 774 | MEMORY_PROP_DIR(fbx->ds_afbc, depth_stencil_afbc_metadata); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 775 | pandecode_prop("depth_stencil_afbc_stride = %d", |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 776 | fbx->ds_afbc.depth_stencil_afbc_stride); |
Alyssa Rosenzweig | 0c1874a | 2019-07-12 08:47:35 -0700 | [diff] [blame] | 777 | MEMORY_PROP_DIR(fbx->ds_afbc, depth_stencil); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 778 | |
Icecream95 | 9ac106d | 2020-06-02 14:13:03 +1200 | [diff] [blame] | 779 | pandecode_log(".flags = "); |
| 780 | pandecode_log_decoded_flags(afbc_fmt_flag_info, fbx->ds_afbc.flags); |
| 781 | pandecode_log_cont(",\n"); |
| 782 | |
| 783 | if (fbx->ds_afbc.padding) { |
Alyssa Rosenzweig | 89c5370 | 2019-08-20 11:18:46 -0700 | [diff] [blame] | 784 | pandecode_msg("XXX: Depth/stencil AFBC zeros tripped\n"); |
Icecream95 | 9ac106d | 2020-06-02 14:13:03 +1200 | [diff] [blame] | 785 | pandecode_prop("padding = 0x%" PRIx64, fbx->ds_afbc.padding); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 786 | } |
| 787 | |
| 788 | pandecode_indent--; |
| 789 | pandecode_log("},\n"); |
| 790 | } else { |
| 791 | pandecode_log(".ds_linear = {\n"); |
| 792 | pandecode_indent++; |
| 793 | |
| 794 | if (fbx->ds_linear.depth) { |
Alyssa Rosenzweig | 0c1874a | 2019-07-12 08:47:35 -0700 | [diff] [blame] | 795 | MEMORY_PROP_DIR(fbx->ds_linear, depth); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 796 | pandecode_prop("depth_stride = %d", |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 797 | fbx->ds_linear.depth_stride); |
Alyssa Rosenzweig | 5e38d95 | 2020-07-03 11:27:48 -0400 | [diff] [blame] | 798 | pandecode_prop("depth_layer_stride = %d", |
| 799 | fbx->ds_linear.depth_layer_stride); |
| 800 | } else if (fbx->ds_linear.depth_stride || fbx->ds_linear.depth_layer_stride) { |
| 801 | pandecode_msg("XXX: depth stride zero tripped %d %d\n", fbx->ds_linear.depth_stride, fbx->ds_linear.depth_layer_stride); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 802 | } |
| 803 | |
| 804 | if (fbx->ds_linear.stencil) { |
Alyssa Rosenzweig | 0c1874a | 2019-07-12 08:47:35 -0700 | [diff] [blame] | 805 | MEMORY_PROP_DIR(fbx->ds_linear, stencil); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 806 | pandecode_prop("stencil_stride = %d", |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 807 | fbx->ds_linear.stencil_stride); |
Alyssa Rosenzweig | 5e38d95 | 2020-07-03 11:27:48 -0400 | [diff] [blame] | 808 | pandecode_prop("stencil_layer_stride = %d", |
| 809 | fbx->ds_linear.stencil_layer_stride); |
| 810 | } else if (fbx->ds_linear.stencil_stride || fbx->ds_linear.stencil_layer_stride) { |
| 811 | pandecode_msg("XXX: stencil stride zero tripped %d %d\n", fbx->ds_linear.stencil_stride, fbx->ds_linear.stencil_layer_stride); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 812 | } |
| 813 | |
| 814 | if (fbx->ds_linear.depth_stride_zero || |
Alyssa Rosenzweig | 5e38d95 | 2020-07-03 11:27:48 -0400 | [diff] [blame] | 815 | fbx->ds_linear.stencil_stride_zero) { |
Alyssa Rosenzweig | 89c5370 | 2019-08-20 11:18:46 -0700 | [diff] [blame] | 816 | pandecode_msg("XXX: Depth/stencil zeros tripped\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 817 | pandecode_prop("depth_stride_zero = 0x%x", |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 818 | fbx->ds_linear.depth_stride_zero); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 819 | pandecode_prop("stencil_stride_zero = 0x%x", |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 820 | fbx->ds_linear.stencil_stride_zero); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 821 | } |
| 822 | |
| 823 | pandecode_indent--; |
| 824 | pandecode_log("},\n"); |
| 825 | } |
| 826 | |
Alyssa Rosenzweig | 81a3191 | 2020-04-06 19:45:30 -0400 | [diff] [blame] | 827 | if (fbx->clear_color_1 | fbx->clear_color_2) { |
| 828 | pandecode_prop("clear_color_1 = 0x%" PRIx32, fbx->clear_color_1); |
| 829 | pandecode_prop("clear_color_2 = 0x%" PRIx32, fbx->clear_color_2); |
| 830 | } |
| 831 | |
| 832 | if (fbx->zero3) { |
Alyssa Rosenzweig | 89c5370 | 2019-08-20 11:18:46 -0700 | [diff] [blame] | 833 | pandecode_msg("XXX: fb_extra zeros tripped\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 834 | pandecode_prop("zero3 = 0x%" PRIx64, fbx->zero3); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 835 | } |
| 836 | |
| 837 | pandecode_indent--; |
| 838 | pandecode_log("};\n"); |
| 839 | |
Alyssa Rosenzweig | 6d9ee3e | 2020-02-10 08:51:37 -0500 | [diff] [blame] | 840 | gpu_va += sizeof(struct mali_framebuffer_extra); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 841 | } |
| 842 | |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 843 | if (is_fragment) |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 844 | pandecode_render_target(gpu_va, job_no, fb); |
Alyssa Rosenzweig | a9fc1c8 | 2019-06-23 11:29:46 -0700 | [diff] [blame] | 845 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 846 | return info; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | static void |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 850 | pandecode_attributes(const struct pandecode_mapped_memory *mem, |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 851 | mali_ptr addr, int job_no, char *suffix, |
Alyssa Rosenzweig | f4678f3 | 2019-08-22 13:27:38 -0700 | [diff] [blame] | 852 | int count, bool varying, enum mali_job_type job_type) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 853 | { |
Alyssa Rosenzweig | 4e3fe54 | 2020-08-14 16:03:12 -0400 | [diff] [blame] | 854 | char *prefix = varying ? "Varying" : "Attribute"; |
Alyssa Rosenzweig | ed464e0 | 2019-08-22 13:07:01 -0700 | [diff] [blame] | 855 | assert(addr); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 856 | |
Alyssa Rosenzweig | ed464e0 | 2019-08-22 13:07:01 -0700 | [diff] [blame] | 857 | if (!count) { |
| 858 | pandecode_msg("warn: No %s records\n", prefix); |
Alyssa Rosenzweig | 5ad8301 | 2019-08-08 09:23:29 -0700 | [diff] [blame] | 859 | return; |
| 860 | } |
| 861 | |
Alyssa Rosenzweig | 4e3fe54 | 2020-08-14 16:03:12 -0400 | [diff] [blame] | 862 | MAP_ADDR(ATTRIBUTE_BUFFER, addr, cl); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 863 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 864 | for (int i = 0; i < count; ++i) { |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 865 | pan_unpack(cl + i * MALI_ATTRIBUTE_BUFFER_LENGTH, ATTRIBUTE_BUFFER, temp); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 866 | DUMP_UNPACKED(ATTRIBUTE_BUFFER, temp, "%s:\n", prefix); |
Alyssa Rosenzweig | f4678f3 | 2019-08-22 13:27:38 -0700 | [diff] [blame] | 867 | |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 868 | if (temp.type != MALI_ATTRIBUTE_TYPE_1D_NPOT_DIVISOR) |
| 869 | continue; |
| 870 | |
| 871 | pan_unpack(cl + (i + 1) * MALI_ATTRIBUTE_BUFFER_LENGTH, |
| 872 | ATTRIBUTE_BUFFER_CONTINUATION_NPOT, temp2); |
| 873 | pan_print(pandecode_dump_stream, ATTRIBUTE_BUFFER_CONTINUATION_NPOT, |
| 874 | temp2, (pandecode_indent + 1) * 2); |
Alyssa Rosenzweig | 3b3d965 | 2019-12-19 12:28:42 -0500 | [diff] [blame] | 875 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 876 | } |
| 877 | |
| 878 | static mali_ptr |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 879 | pandecode_shader_address(const char *name, mali_ptr ptr) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 880 | { |
| 881 | /* TODO: Decode flags */ |
| 882 | mali_ptr shader_ptr = ptr & ~15; |
| 883 | |
| 884 | char *a = pointer_as_memory_reference(shader_ptr); |
| 885 | pandecode_prop("%s = (%s) | %d", name, a, (int) (ptr & 15)); |
| 886 | free(a); |
| 887 | |
| 888 | return shader_ptr; |
| 889 | } |
| 890 | |
Alyssa Rosenzweig | ae70538 | 2019-05-18 20:48:43 +0000 | [diff] [blame] | 891 | /* Decodes a Bifrost blend constant. See the notes in bifrost_blend_rt */ |
| 892 | |
| 893 | static unsigned |
| 894 | decode_bifrost_constant(u16 constant) |
| 895 | { |
| 896 | float lo = (float) (constant & 0xFF); |
| 897 | float hi = (float) (constant >> 8); |
| 898 | |
| 899 | return (hi / 255.0) + (lo / 65535.0); |
| 900 | } |
| 901 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 902 | static mali_ptr |
| 903 | pandecode_bifrost_blend(void *descs, int job_no, int rt_no) |
| 904 | { |
| 905 | struct bifrost_blend_rt *b = |
| 906 | ((struct bifrost_blend_rt *) descs) + rt_no; |
| 907 | |
| 908 | pandecode_log("struct bifrost_blend_rt blend_rt_%d_%d = {\n", job_no, rt_no); |
| 909 | pandecode_indent++; |
| 910 | |
Alyssa Rosenzweig | ae70538 | 2019-05-18 20:48:43 +0000 | [diff] [blame] | 911 | pandecode_prop("flags = 0x%" PRIx16, b->flags); |
| 912 | pandecode_prop("constant = 0x%" PRIx8 " /* %f */", |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 913 | b->constant, decode_bifrost_constant(b->constant)); |
Alyssa Rosenzweig | ae70538 | 2019-05-18 20:48:43 +0000 | [diff] [blame] | 914 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 915 | /* TODO figure out blend shader enable bit */ |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 916 | DUMP_CL(BLEND_EQUATION, &b->equation, "Equation:\n"); |
Tomeu Vizoso | 3c98c45 | 2020-04-24 08:40:51 +0200 | [diff] [blame] | 917 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 918 | pandecode_prop("unk2 = 0x%" PRIx16, b->unk2); |
| 919 | pandecode_prop("index = 0x%" PRIx16, b->index); |
Tomeu Vizoso | 3c98c45 | 2020-04-24 08:40:51 +0200 | [diff] [blame] | 920 | |
Alyssa Rosenzweig | 0c621dc | 2020-08-11 21:30:46 -0400 | [diff] [blame] | 921 | pandecode_log(".format = %s", mali_format_as_str(b->format)); |
Tomeu Vizoso | 3c98c45 | 2020-04-24 08:40:51 +0200 | [diff] [blame] | 922 | pandecode_swizzle(b->swizzle, b->format); |
| 923 | pandecode_log_cont(",\n"); |
| 924 | |
| 925 | pandecode_prop("swizzle = 0x%" PRIx32, b->swizzle); |
| 926 | pandecode_prop("format = 0x%" PRIx32, b->format); |
| 927 | |
| 928 | if (b->zero1) { |
| 929 | pandecode_msg("XXX: pandecode_bifrost_blend zero1 tripped\n"); |
| 930 | pandecode_prop("zero1 = 0x%" PRIx32, b->zero1); |
| 931 | } |
| 932 | |
| 933 | pandecode_log(".shader_type = "); |
| 934 | switch(b->shader_type) { |
| 935 | case BIFROST_BLEND_F16: |
| 936 | pandecode_log_cont("BIFROST_BLEND_F16"); |
| 937 | break; |
| 938 | case BIFROST_BLEND_F32: |
| 939 | pandecode_log_cont("BIFROST_BLEND_F32"); |
| 940 | break; |
| 941 | case BIFROST_BLEND_I32: |
| 942 | pandecode_log_cont("BIFROST_BLEND_I32"); |
| 943 | break; |
| 944 | case BIFROST_BLEND_U32: |
| 945 | pandecode_log_cont("BIFROST_BLEND_U32"); |
| 946 | break; |
| 947 | case BIFROST_BLEND_I16: |
| 948 | pandecode_log_cont("BIFROST_BLEND_I16"); |
| 949 | break; |
| 950 | case BIFROST_BLEND_U16: |
| 951 | pandecode_log_cont("BIFROST_BLEND_U16"); |
| 952 | break; |
| 953 | } |
| 954 | pandecode_log_cont(",\n"); |
| 955 | |
| 956 | if (b->zero2) { |
| 957 | pandecode_msg("XXX: pandecode_bifrost_blend zero2 tripped\n"); |
| 958 | pandecode_prop("zero2 = 0x%" PRIx32, b->zero2); |
| 959 | } |
| 960 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 961 | pandecode_prop("shader = 0x%" PRIx32, b->shader); |
| 962 | |
| 963 | pandecode_indent--; |
| 964 | pandecode_log("},\n"); |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 965 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 966 | return 0; |
| 967 | } |
| 968 | |
| 969 | static mali_ptr |
| 970 | pandecode_midgard_blend(union midgard_blend *blend, bool is_shader) |
| 971 | { |
Alyssa Rosenzweig | 9ce45ac | 2019-08-21 08:59:57 -0700 | [diff] [blame] | 972 | /* constant/equation is in a union */ |
| 973 | if (!blend->shader) |
Alyssa Rosenzweig | b6d46d0 | 2019-06-19 09:31:16 -0700 | [diff] [blame] | 974 | return 0; |
| 975 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 976 | pandecode_log(".blend = {\n"); |
| 977 | pandecode_indent++; |
| 978 | |
| 979 | if (is_shader) { |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 980 | pandecode_shader_address("shader", blend->shader); |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 981 | } else { |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 982 | DUMP_CL(BLEND_EQUATION, &blend->equation, "Equation:\n"); |
Alyssa Rosenzweig | ae70538 | 2019-05-18 20:48:43 +0000 | [diff] [blame] | 983 | pandecode_prop("constant = %f", blend->constant); |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 984 | } |
| 985 | |
| 986 | pandecode_indent--; |
| 987 | pandecode_log("},\n"); |
| 988 | |
| 989 | /* Return blend shader to disassemble if present */ |
| 990 | return is_shader ? (blend->shader & ~0xF) : 0; |
| 991 | } |
| 992 | |
| 993 | static mali_ptr |
| 994 | pandecode_midgard_blend_mrt(void *descs, int job_no, int rt_no) |
| 995 | { |
| 996 | struct midgard_blend_rt *b = |
| 997 | ((struct midgard_blend_rt *) descs) + rt_no; |
| 998 | |
| 999 | /* Flags determine presence of blend shader */ |
Alyssa Rosenzweig | 94c9f87 | 2020-08-18 17:06:01 -0400 | [diff] [blame] | 1000 | bool is_shader = b->flags.opaque[0] & 0x2; |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1001 | |
| 1002 | pandecode_log("struct midgard_blend_rt blend_rt_%d_%d = {\n", job_no, rt_no); |
| 1003 | pandecode_indent++; |
| 1004 | |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1005 | DUMP_CL(BLEND_FLAGS, &b->flags, "Flags:\n"); |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1006 | |
Alyssa Rosenzweig | 9ffe061 | 2019-07-12 08:45:51 -0700 | [diff] [blame] | 1007 | union midgard_blend blend = b->blend; |
| 1008 | mali_ptr shader = pandecode_midgard_blend(&blend, is_shader); |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1009 | |
| 1010 | pandecode_indent--; |
| 1011 | pandecode_log("};\n"); |
| 1012 | |
| 1013 | return shader; |
| 1014 | } |
| 1015 | |
Alyssa Rosenzweig | 2208eb9 | 2019-08-20 13:59:26 -0700 | [diff] [blame] | 1016 | /* Attributes and varyings have descriptor records, which contain information |
| 1017 | * about their format and ordering with the attribute/varying buffers. We'll |
| 1018 | * want to validate that the combinations specified are self-consistent. |
| 1019 | */ |
| 1020 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1021 | static int |
Alyssa Rosenzweig | 6855228 | 2020-08-26 16:50:16 -0400 | [diff] [blame] | 1022 | pandecode_attribute_meta(int count, mali_ptr attribute, bool varying, char *suffix) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1023 | { |
Alyssa Rosenzweig | 6855228 | 2020-08-26 16:50:16 -0400 | [diff] [blame] | 1024 | for (int i = 0; i < count; ++i, attribute += MALI_ATTRIBUTE_LENGTH) |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1025 | DUMP_ADDR(ATTRIBUTE, attribute, "%s:\n", varying ? "Varying" : "Attribute"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1026 | |
Alyssa Rosenzweig | 2c8a722 | 2020-08-13 13:27:16 -0400 | [diff] [blame] | 1027 | return count; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1028 | } |
| 1029 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1030 | /* return bits [lo, hi) of word */ |
| 1031 | static u32 |
| 1032 | bits(u32 word, u32 lo, u32 hi) |
| 1033 | { |
| 1034 | if (hi - lo >= 32) |
| 1035 | return word; // avoid undefined behavior with the shift |
| 1036 | |
| 1037 | return (word >> lo) & ((1 << (hi - lo)) - 1); |
| 1038 | } |
| 1039 | |
| 1040 | static void |
Alyssa Rosenzweig | 385a4f7 | 2019-12-24 22:33:47 -0500 | [diff] [blame] | 1041 | 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] | 1042 | { |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1043 | /* Decode invocation_count. See the comment before the definition of |
| 1044 | * invocation_count for an explanation. |
| 1045 | */ |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 1046 | struct mali_invocation_packed invocation_packed = p->invocation; |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1047 | pan_unpack(&invocation_packed, INVOCATION, invocation); |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 1048 | |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 1049 | unsigned size_x = bits(invocation.invocations, 0, invocation.size_y_shift) + 1; |
| 1050 | unsigned size_y = bits(invocation.invocations, invocation.size_y_shift, invocation.size_z_shift) + 1; |
| 1051 | 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] | 1052 | |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 1053 | unsigned groups_x = bits(invocation.invocations, invocation.workgroups_x_shift, invocation.workgroups_y_shift) + 1; |
| 1054 | unsigned groups_y = bits(invocation.invocations, invocation.workgroups_y_shift, invocation.workgroups_z_shift) + 1; |
| 1055 | unsigned groups_z = bits(invocation.invocations, invocation.workgroups_z_shift, 32) + 1; |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 1056 | |
| 1057 | /* Even though we have this decoded, we want to ensure that the |
| 1058 | * representation is "unique" so we don't lose anything by printing only |
| 1059 | * the final result. More specifically, we need to check that we were |
| 1060 | * passed something in canonical form, since the definition per the |
| 1061 | * hardware is inherently not unique. How? Well, take the resulting |
| 1062 | * decode and pack it ourselves! If it is bit exact with what we |
| 1063 | * decoded, we're good to go. */ |
| 1064 | |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 1065 | struct mali_invocation_packed ref; |
Alyssa Rosenzweig | 385a4f7 | 2019-12-24 22:33:47 -0500 | [diff] [blame] | 1066 | 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] | 1067 | |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 1068 | if (memcmp(&ref, &invocation_packed, sizeof(ref))) { |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 1069 | pandecode_msg("XXX: non-canonical workgroups packing\n"); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1070 | DUMP_UNPACKED(INVOCATION, invocation, "Invocation:\n") |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 1071 | } |
| 1072 | |
| 1073 | /* Regardless, print the decode */ |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1074 | pandecode_log("Invocation (%d, %d, %d) x (%d, %d, %d)\n", |
| 1075 | size_x, size_y, size_z, |
| 1076 | groups_x, groups_y, groups_z); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1077 | |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 1078 | struct mali_primitive_packed prim_packed = p->primitive; |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1079 | pan_unpack(&prim_packed, PRIMITIVE, primitive); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1080 | DUMP_UNPACKED(PRIMITIVE, primitive, "Primitive:\n"); |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 1081 | |
| 1082 | /* Validate an index buffer is present if we need one. TODO: verify |
| 1083 | * relationship between invocation_count and index_count */ |
| 1084 | |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 1085 | if (primitive.indices) { |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 1086 | /* Grab the size */ |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 1087 | unsigned size = (primitive.index_type == MALI_INDEX_TYPE_UINT32) ? |
| 1088 | sizeof(uint32_t) : primitive.index_type; |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 1089 | |
| 1090 | /* Ensure we got a size, and if so, validate the index buffer |
| 1091 | * is large enough to hold a full set of indices of the given |
| 1092 | * size */ |
| 1093 | |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 1094 | if (!size) |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 1095 | pandecode_msg("XXX: index size missing\n"); |
| 1096 | else |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 1097 | pandecode_validate_buffer(primitive.indices, primitive.index_count * size); |
| 1098 | } else if (primitive.index_type) |
| 1099 | pandecode_msg("XXX: unexpected index size\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1100 | } |
| 1101 | |
| 1102 | static void |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 1103 | pandecode_uniform_buffers(mali_ptr pubufs, int ubufs_count, int job_no) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1104 | { |
| 1105 | struct pandecode_mapped_memory *umem = pandecode_find_mapped_gpu_mem_containing(pubufs); |
Alyssa Rosenzweig | 7d3c48f | 2020-02-16 17:01:02 -0500 | [diff] [blame] | 1106 | uint64_t *PANDECODE_PTR_VAR(ubufs, umem, pubufs); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1107 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1108 | for (int i = 0; i < ubufs_count; i++) { |
Alyssa Rosenzweig | 7d3c48f | 2020-02-16 17:01:02 -0500 | [diff] [blame] | 1109 | unsigned size = (ubufs[i] & ((1 << 10) - 1)) * 16; |
| 1110 | mali_ptr addr = (ubufs[i] >> 10) << 2; |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1111 | |
| 1112 | pandecode_validate_buffer(addr, size); |
| 1113 | |
Alyssa Rosenzweig | 7d3c48f | 2020-02-16 17:01:02 -0500 | [diff] [blame] | 1114 | char *ptr = pointer_as_memory_reference(addr); |
Alyssa Rosenzweig | 6ec33b4 | 2019-08-21 11:46:06 -0700 | [diff] [blame] | 1115 | pandecode_log("ubuf_%d[%u] = %s;\n", i, size, ptr); |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1116 | free(ptr); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1117 | } |
| 1118 | |
Alyssa Rosenzweig | 6ec33b4 | 2019-08-21 11:46:06 -0700 | [diff] [blame] | 1119 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1120 | } |
| 1121 | |
| 1122 | static void |
Alyssa Rosenzweig | ae84f16 | 2019-08-22 11:30:13 -0700 | [diff] [blame] | 1123 | pandecode_uniforms(mali_ptr uniforms, unsigned uniform_count) |
| 1124 | { |
| 1125 | pandecode_validate_buffer(uniforms, uniform_count * 16); |
| 1126 | |
| 1127 | char *ptr = pointer_as_memory_reference(uniforms); |
| 1128 | pandecode_log("vec4 uniforms[%u] = %s;\n", uniform_count, ptr); |
| 1129 | free(ptr); |
| 1130 | } |
| 1131 | |
Alyssa Rosenzweig | 09671c8 | 2019-12-23 11:40:40 -0500 | [diff] [blame] | 1132 | static const char * |
| 1133 | shader_type_for_job(unsigned type) |
| 1134 | { |
| 1135 | switch (type) { |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1136 | case MALI_JOB_TYPE_VERTEX: return "VERTEX"; |
| 1137 | case MALI_JOB_TYPE_TILER: return "FRAGMENT"; |
| 1138 | case MALI_JOB_TYPE_COMPUTE: return "COMPUTE"; |
Alyssa Rosenzweig | 8004906 | 2020-08-26 16:52:53 -0400 | [diff] [blame] | 1139 | default: return "UNKNOWN"; |
Alyssa Rosenzweig | 09671c8 | 2019-12-23 11:40:40 -0500 | [diff] [blame] | 1140 | } |
| 1141 | } |
| 1142 | |
Alyssa Rosenzweig | c4a4f3d | 2019-08-14 09:19:54 -0700 | [diff] [blame] | 1143 | static unsigned shader_id = 0; |
| 1144 | |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 1145 | static struct midgard_disasm_stats |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1146 | pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type, |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1147 | bool is_bifrost, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1148 | { |
| 1149 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(shader_ptr); |
| 1150 | uint8_t *PANDECODE_PTR_VAR(code, mem, shader_ptr); |
| 1151 | |
| 1152 | /* Compute maximum possible size */ |
| 1153 | size_t sz = mem->length - (shader_ptr - mem->gpu_va); |
| 1154 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1155 | /* Print some boilerplate to clearly denote the assembly (which doesn't |
| 1156 | * obey indentation rules), and actually do the disassembly! */ |
| 1157 | |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 1158 | pandecode_log_cont("\n\n"); |
Alyssa Rosenzweig | 50382df | 2019-05-18 18:58:56 +0000 | [diff] [blame] | 1159 | |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 1160 | struct midgard_disasm_stats stats; |
Alyssa Rosenzweig | c4a4f3d | 2019-08-14 09:19:54 -0700 | [diff] [blame] | 1161 | |
Alyssa Rosenzweig | 50382df | 2019-05-18 18:58:56 +0000 | [diff] [blame] | 1162 | if (is_bifrost) { |
Alyssa Rosenzweig | c88f816 | 2020-03-27 22:34:15 -0400 | [diff] [blame] | 1163 | disassemble_bifrost(pandecode_dump_stream, code, sz, true); |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 1164 | |
| 1165 | /* TODO: Extend stats to Bifrost */ |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1166 | stats.texture_count = -128; |
| 1167 | stats.sampler_count = -128; |
| 1168 | stats.attribute_count = -128; |
| 1169 | stats.varying_count = -128; |
| 1170 | stats.uniform_count = -128; |
| 1171 | stats.uniform_buffer_count = -128; |
| 1172 | stats.work_count = -128; |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 1173 | |
| 1174 | stats.instruction_count = 0; |
| 1175 | stats.bundle_count = 0; |
| 1176 | stats.quadword_count = 0; |
Alyssa Rosenzweig | d6d6d63 | 2019-08-30 17:00:09 -0700 | [diff] [blame] | 1177 | stats.helper_invocations = false; |
Alyssa Rosenzweig | 50382df | 2019-05-18 18:58:56 +0000 | [diff] [blame] | 1178 | } else { |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 1179 | stats = disassemble_midgard(pandecode_dump_stream, |
| 1180 | code, sz, gpu_id, |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1181 | type == MALI_JOB_TYPE_TILER ? |
Alyssa Rosenzweig | ac14fac | 2019-11-07 09:31:02 -0500 | [diff] [blame] | 1182 | MESA_SHADER_FRAGMENT : MESA_SHADER_VERTEX); |
Alyssa Rosenzweig | 50382df | 2019-05-18 18:58:56 +0000 | [diff] [blame] | 1183 | } |
| 1184 | |
Alyssa Rosenzweig | c088a3b | 2020-08-26 16:52:23 -0400 | [diff] [blame] | 1185 | unsigned nr_threads = |
| 1186 | (stats.work_count <= 4) ? 4 : |
| 1187 | (stats.work_count <= 8) ? 2 : |
| 1188 | 1; |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 1189 | |
Alyssa Rosenzweig | c088a3b | 2020-08-26 16:52:23 -0400 | [diff] [blame] | 1190 | pandecode_log_cont("shader%d - MESA_SHADER_%s shader: " |
| 1191 | "%u inst, %u bundles, %u quadwords, " |
| 1192 | "%u registers, %u threads, 0 loops, 0:0 spills:fills\n\n\n", |
| 1193 | shader_id++, |
| 1194 | shader_type_for_job(type), |
| 1195 | stats.instruction_count, stats.bundle_count, stats.quadword_count, |
| 1196 | stats.work_count, nr_threads); |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 1197 | |
| 1198 | return stats; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1199 | } |
| 1200 | |
| 1201 | static void |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 1202 | pandecode_texture_payload(mali_ptr payload, |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 1203 | enum mali_texture_dimension dim, |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 1204 | enum mali_texture_layout layout, |
| 1205 | bool manual_stride, |
| 1206 | uint8_t levels, |
| 1207 | uint16_t depth, |
| 1208 | uint16_t array_size, |
| 1209 | struct pandecode_mapped_memory *tmem) |
| 1210 | { |
| 1211 | pandecode_log(".payload = {\n"); |
| 1212 | pandecode_indent++; |
| 1213 | |
| 1214 | /* A bunch of bitmap pointers follow. |
| 1215 | * We work out the correct number, |
| 1216 | * based on the mipmap/cubemap |
| 1217 | * properties, but dump extra |
| 1218 | * possibilities to futureproof */ |
| 1219 | |
| 1220 | int bitmap_count = levels + 1; |
| 1221 | |
| 1222 | /* Miptree for each face */ |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 1223 | if (dim == MALI_TEXTURE_DIMENSION_CUBE) |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 1224 | bitmap_count *= 6; |
Alyssa Rosenzweig | eba9bcd | 2020-06-30 16:21:30 -0400 | [diff] [blame] | 1225 | |
| 1226 | /* Array of layers */ |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 1227 | bitmap_count *= depth; |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 1228 | |
| 1229 | /* Array of textures */ |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 1230 | bitmap_count *= array_size; |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 1231 | |
| 1232 | /* Stride for each element */ |
| 1233 | if (manual_stride) |
| 1234 | bitmap_count *= 2; |
| 1235 | |
| 1236 | mali_ptr *pointers_and_strides = pandecode_fetch_gpu_mem(tmem, |
| 1237 | payload, sizeof(mali_ptr) * bitmap_count); |
| 1238 | for (int i = 0; i < bitmap_count; ++i) { |
| 1239 | /* How we dump depends if this is a stride or a pointer */ |
| 1240 | |
| 1241 | if (manual_stride && (i & 1)) { |
| 1242 | /* signed 32-bit snuck in as a 64-bit pointer */ |
| 1243 | uint64_t stride_set = pointers_and_strides[i]; |
| 1244 | uint32_t clamped_stride = stride_set; |
| 1245 | int32_t stride = clamped_stride; |
| 1246 | assert(stride_set == clamped_stride); |
| 1247 | pandecode_log("(mali_ptr) %d /* stride */, \n", stride); |
| 1248 | } else { |
| 1249 | char *a = pointer_as_memory_reference(pointers_and_strides[i]); |
| 1250 | pandecode_log("%s, \n", a); |
| 1251 | free(a); |
| 1252 | } |
| 1253 | } |
| 1254 | |
| 1255 | pandecode_indent--; |
| 1256 | pandecode_log("},\n"); |
| 1257 | } |
| 1258 | |
| 1259 | static void |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 1260 | pandecode_texture(mali_ptr u, |
| 1261 | struct pandecode_mapped_memory *tmem, |
| 1262 | unsigned job_no, unsigned tex) |
| 1263 | { |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 1264 | struct pandecode_mapped_memory *mapped_mem = pandecode_find_mapped_gpu_mem_containing(u); |
| 1265 | 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] | 1266 | |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1267 | pan_unpack(cl, MIDGARD_TEXTURE, temp); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1268 | DUMP_UNPACKED(MIDGARD_TEXTURE, temp, "Texture:\n") |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 1269 | |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1270 | pandecode_indent++; |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 1271 | pandecode_texture_payload(u + MALI_MIDGARD_TEXTURE_LENGTH, |
| 1272 | temp.dimension, temp.texel_ordering, temp.manual_stride, |
| 1273 | temp.levels, temp.depth, temp.array_size, mapped_mem); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1274 | pandecode_indent--; |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 1275 | } |
| 1276 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1277 | static void |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 1278 | pandecode_bifrost_texture( |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 1279 | const void *cl, |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 1280 | unsigned job_no, |
| 1281 | unsigned tex) |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1282 | { |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1283 | pan_unpack(cl, BIFROST_TEXTURE, temp); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1284 | DUMP_UNPACKED(BIFROST_TEXTURE, temp, "Texture:\n") |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1285 | |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 1286 | 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] | 1287 | pandecode_indent++; |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 1288 | pandecode_texture_payload(temp.surfaces, temp.dimension, temp.texel_ordering, |
| 1289 | true, temp.levels, 1, 1, tmem); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1290 | pandecode_indent--; |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1291 | } |
| 1292 | |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1293 | /* 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 */ |
| 1294 | |
| 1295 | static void |
| 1296 | pandecode_shader_prop(const char *name, unsigned claim, signed truth, bool fuzzy) |
| 1297 | { |
| 1298 | /* Nothing to do */ |
| 1299 | if (claim == truth) |
| 1300 | return; |
| 1301 | |
Alyssa Rosenzweig | 5815f33 | 2020-02-25 17:29:55 -0500 | [diff] [blame] | 1302 | if (fuzzy && (truth < 0)) |
| 1303 | 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] | 1304 | |
| 1305 | if ((truth >= 0) && !fuzzy) { |
Alyssa Rosenzweig | f48136e | 2019-08-22 09:02:48 -0700 | [diff] [blame] | 1306 | pandecode_msg("%s: expected %s = %d, claimed %u\n", |
| 1307 | (truth < claim) ? "warn" : "XXX", |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1308 | name, truth, claim); |
| 1309 | } else if ((claim > -truth) && !fuzzy) { |
| 1310 | pandecode_msg("XXX: expected %s <= %u, claimed %u\n", |
| 1311 | name, -truth, claim); |
| 1312 | } else if (fuzzy && (claim < truth)) |
| 1313 | pandecode_msg("XXX: expected %s >= %u, claimed %u\n", |
| 1314 | name, truth, claim); |
| 1315 | |
| 1316 | pandecode_log(".%s = %" PRId16, name, claim); |
| 1317 | |
| 1318 | if (fuzzy) |
| 1319 | pandecode_log_cont(" /* %u used */", truth); |
| 1320 | |
| 1321 | pandecode_log_cont(",\n"); |
| 1322 | } |
| 1323 | |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 1324 | static void |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 1325 | 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] | 1326 | bool is_bifrost, unsigned gpu_id) |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 1327 | { |
| 1328 | struct midgard_disasm_stats stats = |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1329 | pandecode_shader_disassemble(shader, job_no, job_type, is_bifrost, gpu_id); |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 1330 | |
| 1331 | bool has_texture = (stats.texture_count > 0); |
| 1332 | bool has_sampler = (stats.sampler_count > 0); |
| 1333 | bool has_attribute = (stats.attribute_count > 0); |
| 1334 | bool has_varying = (stats.varying_count > 0); |
| 1335 | bool has_uniform = (stats.uniform_count > 0); |
| 1336 | bool has_ubo = (stats.uniform_buffer_count > 0); |
| 1337 | |
| 1338 | if (has_texture || has_sampler) |
| 1339 | pandecode_msg("XXX: blend shader accessing textures\n"); |
| 1340 | |
| 1341 | if (has_attribute || has_varying) |
| 1342 | pandecode_msg("XXX: blend shader accessing interstage\n"); |
| 1343 | |
| 1344 | if (has_uniform || has_ubo) |
| 1345 | pandecode_msg("XXX: blend shader accessing uniforms\n"); |
| 1346 | } |
| 1347 | |
| 1348 | static void |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1349 | pandecode_textures(mali_ptr textures, unsigned texture_count, int job_no, bool is_bifrost) |
| 1350 | { |
| 1351 | struct pandecode_mapped_memory *mmem = pandecode_find_mapped_gpu_mem_containing(textures); |
| 1352 | |
| 1353 | if (!mmem) |
| 1354 | return; |
| 1355 | |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 1356 | pandecode_log("Textures (%"PRIx64"):\n", textures); |
| 1357 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1358 | if (is_bifrost) { |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 1359 | const void *cl = pandecode_fetch_gpu_mem(mmem, |
| 1360 | textures, MALI_BIFROST_TEXTURE_LENGTH * |
| 1361 | texture_count); |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1362 | |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 1363 | for (unsigned tex = 0; tex < texture_count; ++tex) { |
| 1364 | pandecode_bifrost_texture(cl + |
| 1365 | MALI_BIFROST_TEXTURE_LENGTH * tex, |
| 1366 | job_no, tex); |
| 1367 | } |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1368 | } else { |
| 1369 | mali_ptr *PANDECODE_PTR_VAR(u, mmem, textures); |
| 1370 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1371 | for (int tex = 0; tex < texture_count; ++tex) { |
| 1372 | mali_ptr *PANDECODE_PTR_VAR(u, mmem, textures + tex * sizeof(mali_ptr)); |
| 1373 | char *a = pointer_as_memory_reference(*u); |
| 1374 | pandecode_log("%s,\n", a); |
| 1375 | free(a); |
| 1376 | } |
| 1377 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1378 | /* Now, finally, descend down into the texture descriptor */ |
| 1379 | for (unsigned tex = 0; tex < texture_count; ++tex) { |
| 1380 | mali_ptr *PANDECODE_PTR_VAR(u, mmem, textures + tex * sizeof(mali_ptr)); |
| 1381 | struct pandecode_mapped_memory *tmem = pandecode_find_mapped_gpu_mem_containing(*u); |
| 1382 | if (tmem) |
| 1383 | pandecode_texture(*u, tmem, job_no, tex); |
| 1384 | } |
| 1385 | } |
| 1386 | } |
| 1387 | |
| 1388 | static void |
| 1389 | pandecode_samplers(mali_ptr samplers, unsigned sampler_count, int job_no, bool is_bifrost) |
| 1390 | { |
Alyssa Rosenzweig | b10c3c8 | 2020-08-11 18:25:03 -0400 | [diff] [blame] | 1391 | for (int i = 0; i < sampler_count; ++i) { |
| 1392 | if (is_bifrost) { |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1393 | DUMP_ADDR(BIFROST_SAMPLER, samplers + (MALI_BIFROST_SAMPLER_LENGTH * i), "Sampler:\n"); |
Alyssa Rosenzweig | b10c3c8 | 2020-08-11 18:25:03 -0400 | [diff] [blame] | 1394 | } else { |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1395 | DUMP_ADDR(MIDGARD_SAMPLER, samplers + (MALI_MIDGARD_SAMPLER_LENGTH * i), "Sampler:\n"); |
Alyssa Rosenzweig | b10c3c8 | 2020-08-11 18:25:03 -0400 | [diff] [blame] | 1396 | } |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1397 | } |
| 1398 | } |
| 1399 | |
| 1400 | static void |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 1401 | pandecode_vertex_tiler_postfix_pre( |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1402 | const struct MALI_DRAW *p, |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 1403 | int job_no, enum mali_job_type job_type, |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1404 | char *suffix, bool is_bifrost, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1405 | { |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1406 | struct pandecode_mapped_memory *attr_mem; |
| 1407 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1408 | struct pandecode_fbd fbd_info = { |
| 1409 | /* Default for Bifrost */ |
| 1410 | .rt_count = 1 |
| 1411 | }; |
| 1412 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1413 | if (is_bifrost) |
| 1414 | pandecode_compute_fbd(p->shared & ~1, job_no); |
| 1415 | else if (p->shared & MALI_MFBD) |
| 1416 | fbd_info = pandecode_mfbd_bfr((u64) ((uintptr_t) p->shared) & FBD_MASK, job_no, false, job_type == MALI_JOB_TYPE_COMPUTE, false); |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1417 | else if (job_type == MALI_JOB_TYPE_COMPUTE) |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1418 | pandecode_compute_fbd((u64) (uintptr_t) p->shared, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1419 | else |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1420 | 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] | 1421 | |
| 1422 | int varying_count = 0, attribute_count = 0, uniform_count = 0, uniform_buffer_count = 0; |
| 1423 | int texture_count = 0, sampler_count = 0; |
| 1424 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1425 | if (p->state) { |
| 1426 | struct pandecode_mapped_memory *smem = pandecode_find_mapped_gpu_mem_containing(p->state); |
| 1427 | 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] | 1428 | |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1429 | /* Disassemble ahead-of-time to get stats. Initialize with |
| 1430 | * stats for the missing-shader case so we get validation |
| 1431 | * there, too */ |
| 1432 | |
| 1433 | struct midgard_disasm_stats info = { |
| 1434 | .texture_count = 0, |
| 1435 | .sampler_count = 0, |
| 1436 | .attribute_count = 0, |
| 1437 | .varying_count = 0, |
| 1438 | .work_count = 1, |
| 1439 | |
| 1440 | .uniform_count = -128, |
| 1441 | .uniform_buffer_count = 0 |
| 1442 | }; |
Alyssa Rosenzweig | 9b067d9 | 2019-08-21 14:28:36 -0700 | [diff] [blame] | 1443 | |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1444 | pan_unpack(cl, STATE, state); |
Alyssa Rosenzweig | 661b469 | 2020-08-21 10:34:06 -0400 | [diff] [blame] | 1445 | |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1446 | if (state.shader.shader & ~0xF) |
| 1447 | 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] | 1448 | |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1449 | DUMP_UNPACKED(STATE, state, "State:\n"); |
| 1450 | pandecode_indent++; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1451 | |
| 1452 | /* Save for dumps */ |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1453 | attribute_count = state.shader.attribute_count; |
| 1454 | varying_count = state.shader.varying_count; |
| 1455 | texture_count = state.shader.texture_count; |
| 1456 | sampler_count = state.shader.sampler_count; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1457 | |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1458 | fprintf(pandecode_dump_stream, " Properties\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1459 | if (is_bifrost) { |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1460 | pan_unpack(&state.properties, BIFROST_PROPERTIES, bi_props); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1461 | DUMP_UNPACKED(BIFROST_PROPERTIES, bi_props, "Properties:\n"); |
Alyssa Rosenzweig | acf77cb | 2020-08-20 16:41:41 -0400 | [diff] [blame] | 1462 | |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1463 | uniform_count = state.preload.uniform_count; |
Alyssa Rosenzweig | acf77cb | 2020-08-20 16:41:41 -0400 | [diff] [blame] | 1464 | uniform_buffer_count = bi_props.uniform_buffer_count; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1465 | } else { |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1466 | pan_unpack(&state.properties, MIDGARD_PROPERTIES, midg_props); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1467 | DUMP_UNPACKED(MIDGARD_PROPERTIES, midg_props, "Properties:\n") |
Alyssa Rosenzweig | 1b7d4f1 | 2020-08-20 16:25:14 -0400 | [diff] [blame] | 1468 | |
| 1469 | uniform_count = midg_props.uniform_count; |
| 1470 | uniform_buffer_count = midg_props.uniform_buffer_count; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1471 | } |
| 1472 | |
Alyssa Rosenzweig | 661b469 | 2020-08-21 10:34:06 -0400 | [diff] [blame] | 1473 | pandecode_shader_prop("texture_count", texture_count, info.texture_count, false); |
| 1474 | pandecode_shader_prop("sampler_count", sampler_count, info.sampler_count, false); |
| 1475 | pandecode_shader_prop("attribute_count", attribute_count, info.attribute_count, false); |
| 1476 | pandecode_shader_prop("varying_count", varying_count, info.varying_count, false); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1477 | |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 1478 | if (is_bifrost) { |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1479 | uint32_t opaque = state.preload.uniform_count << 15 |
| 1480 | | state.preload.untyped; |
| 1481 | |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 1482 | switch (job_type) { |
| 1483 | case MALI_JOB_TYPE_VERTEX: |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1484 | DUMP_CL(PRELOAD_VERTEX, &opaque, "Preload:\n"); |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 1485 | break; |
| 1486 | case MALI_JOB_TYPE_TILER: |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1487 | DUMP_CL(PRELOAD_FRAGMENT, &opaque, "Preload:\n"); |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 1488 | break; |
| 1489 | case MALI_JOB_TYPE_COMPUTE: |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1490 | DUMP_CL(PRELOAD_COMPUTE, &opaque, "Preload:\n"); |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 1491 | break; |
| 1492 | default: |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1493 | DUMP_CL(PRELOAD, &opaque, "Preload:\n"); |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 1494 | break; |
| 1495 | } |
| 1496 | } |
| 1497 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1498 | if (!is_bifrost) { |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1499 | /* TODO: Blend shaders routing/disasm */ |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1500 | union midgard_blend blend; |
| 1501 | memcpy(&blend, &state.sfbd_blend, sizeof(blend)); |
| 1502 | 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] | 1503 | if (shader & ~0xF) |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1504 | pandecode_blend_shader_disassemble(shader, job_no, job_type, false, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1505 | } |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1506 | pandecode_indent--; |
| 1507 | pandecode_msg("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1508 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1509 | /* MRT blend fields are used whenever MFBD is used, with |
| 1510 | * per-RT descriptors */ |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1511 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1512 | if (job_type == MALI_JOB_TYPE_TILER && (is_bifrost || p->shared & MALI_MFBD)) { |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 1513 | void* blend_base = ((void *) cl) + MALI_STATE_LENGTH; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1514 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1515 | for (unsigned i = 0; i < fbd_info.rt_count; i++) { |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1516 | mali_ptr shader = 0; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1517 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1518 | if (is_bifrost) |
| 1519 | shader = pandecode_bifrost_blend(blend_base, job_no, i); |
| 1520 | else |
| 1521 | shader = pandecode_midgard_blend_mrt(blend_base, job_no, i); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1522 | |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 1523 | if (shader & ~0xF) |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1524 | pandecode_blend_shader_disassemble(shader, job_no, job_type, false, gpu_id); |
Alyssa Rosenzweig | 139708b | 2019-08-21 14:04:05 -0700 | [diff] [blame] | 1525 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1526 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1527 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1528 | } else |
Alyssa Rosenzweig | 5f9a1c7 | 2019-08-21 14:16:32 -0700 | [diff] [blame] | 1529 | pandecode_msg("XXX: missing shader descriptor\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1530 | |
Alyssa Rosenzweig | 7f487e0 | 2020-08-05 19:33:20 -0400 | [diff] [blame] | 1531 | if (p->viewport) |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1532 | DUMP_ADDR(VIEWPORT, p->viewport, "Viewport:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1533 | |
Alyssa Rosenzweig | ed464e0 | 2019-08-22 13:07:01 -0700 | [diff] [blame] | 1534 | unsigned max_attr_index = 0; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1535 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1536 | if (p->attributes) |
| 1537 | max_attr_index = pandecode_attribute_meta(attribute_count, p->attributes, false, suffix); |
Alyssa Rosenzweig | ed464e0 | 2019-08-22 13:07:01 -0700 | [diff] [blame] | 1538 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1539 | if (p->attribute_buffers) { |
| 1540 | attr_mem = pandecode_find_mapped_gpu_mem_containing(p->attribute_buffers); |
| 1541 | 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] | 1542 | } |
| 1543 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1544 | if (p->varyings) { |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1545 | varying_count = pandecode_attribute_meta(varying_count, p->varyings, true, suffix); |
| 1546 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1547 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1548 | if (p->varying_buffers) { |
| 1549 | attr_mem = pandecode_find_mapped_gpu_mem_containing(p->varying_buffers); |
| 1550 | 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] | 1551 | } |
| 1552 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1553 | if (p->uniform_buffers) { |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1554 | if (uniform_buffer_count) |
| 1555 | pandecode_uniform_buffers(p->uniform_buffers, uniform_buffer_count, job_no); |
| 1556 | else |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1557 | pandecode_msg("warn: UBOs specified but not referenced\n"); |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1558 | } else if (uniform_buffer_count) |
| 1559 | pandecode_msg("XXX: UBOs referenced but not specified\n"); |
| 1560 | |
| 1561 | /* We don't want to actually dump uniforms, but we do need to validate |
| 1562 | * that the counts we were given are sane */ |
| 1563 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1564 | if (p->push_uniforms) { |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1565 | if (uniform_count) |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1566 | pandecode_uniforms(p->push_uniforms, uniform_count); |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1567 | else |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1568 | pandecode_msg("warn: Uniforms specified but not referenced\n"); |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1569 | } else if (uniform_count) |
Alyssa Rosenzweig | d7473e2 | 2019-08-21 14:15:05 -0700 | [diff] [blame] | 1570 | pandecode_msg("XXX: Uniforms referenced but not specified\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1571 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1572 | if (p->textures) |
| 1573 | pandecode_textures(p->textures, texture_count, job_no, is_bifrost); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1574 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1575 | if (p->samplers) |
| 1576 | pandecode_samplers(p->samplers, sampler_count, job_no, is_bifrost); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1577 | } |
| 1578 | |
| 1579 | static void |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame^] | 1580 | pandecode_bifrost_tiler_heap(mali_ptr gpu_va, int job_no) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1581 | { |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1582 | 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^] | 1583 | pan_unpack(PANDECODE_PTR(mem, gpu_va, void), BIFROST_TILER_HEAP, h); |
| 1584 | DUMP_UNPACKED(BIFROST_TILER_HEAP, h, "Bifrost Tiler Heap:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1585 | } |
| 1586 | |
| 1587 | static void |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame^] | 1588 | pandecode_bifrost_tiler(mali_ptr gpu_va, int job_no) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1589 | { |
| 1590 | 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^] | 1591 | pan_unpack(PANDECODE_PTR(mem, gpu_va, void), BIFROST_TILER, t); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1592 | |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame^] | 1593 | pandecode_bifrost_tiler_heap(t.heap, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1594 | |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame^] | 1595 | DUMP_UNPACKED(BIFROST_TILER, t, "Bifrost Tiler:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1596 | pandecode_indent++; |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame^] | 1597 | if (t.hierarchy_mask != 0xa && |
| 1598 | t.hierarchy_mask != 0x14 && |
| 1599 | t.hierarchy_mask != 0x28 && |
| 1600 | t.hierarchy_mask != 0x50 && |
| 1601 | t.hierarchy_mask != 0xa0) |
Tomeu Vizoso | 0a0b670 | 2020-04-09 09:39:17 +0200 | [diff] [blame] | 1602 | pandecode_prop("XXX: Unexpected hierarchy_mask (not 0xa, 0x14, 0x28, 0x50 or 0xa0)!"); |
| 1603 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1604 | pandecode_indent--; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1605 | } |
| 1606 | |
| 1607 | static void |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 1608 | pandecode_primitive_size(union midgard_primitive_size u, bool constant) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1609 | { |
Alyssa Rosenzweig | 2608da1 | 2019-06-19 09:35:57 -0700 | [diff] [blame] | 1610 | if (u.pointer == 0x0) |
| 1611 | return; |
| 1612 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1613 | pandecode_log(".primitive_size = {\n"); |
| 1614 | pandecode_indent++; |
| 1615 | |
Alyssa Rosenzweig | b517e36 | 2019-03-15 03:21:27 +0000 | [diff] [blame] | 1616 | if (constant) { |
| 1617 | pandecode_prop("constant = %f", u.constant); |
| 1618 | } else { |
| 1619 | MEMORY_PROP((&u), pointer); |
| 1620 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1621 | |
| 1622 | pandecode_indent--; |
| 1623 | pandecode_log("},\n"); |
| 1624 | } |
| 1625 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1626 | static int |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 1627 | pandecode_vertex_job_bfr(const struct mali_job_descriptor_header *h, |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 1628 | const struct pandecode_mapped_memory *mem, |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1629 | mali_ptr payload, int job_no, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1630 | { |
| 1631 | struct bifrost_payload_vertex *PANDECODE_PTR_VAR(v, mem, payload); |
| 1632 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1633 | struct mali_draw_packed draw_packed; |
| 1634 | memcpy(&draw_packed, &v->postfix, sizeof(draw_packed)); |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1635 | pan_unpack(&draw_packed, DRAW, draw); |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1636 | pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->job_type, "", true, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1637 | |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 1638 | pandecode_vertex_tiler_prefix(&v->prefix, job_no, false); |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1639 | DUMP_CL(DRAW, &draw_packed, "Draw:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1640 | |
| 1641 | return sizeof(*v); |
| 1642 | } |
| 1643 | |
| 1644 | static int |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 1645 | pandecode_tiler_job_bfr(const struct mali_job_descriptor_header *h, |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 1646 | const struct pandecode_mapped_memory *mem, |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1647 | mali_ptr payload, int job_no, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1648 | { |
| 1649 | struct bifrost_payload_tiler *PANDECODE_PTR_VAR(t, mem, payload); |
| 1650 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1651 | struct mali_draw_packed draw_packed; |
| 1652 | memcpy(&draw_packed, &t->postfix, sizeof(draw_packed)); |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1653 | pan_unpack(&draw_packed, DRAW, draw); |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1654 | pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->job_type, "", true, gpu_id); |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame^] | 1655 | pandecode_bifrost_tiler(t->tiler_meta, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1656 | |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 1657 | pandecode_vertex_tiler_prefix(&t->prefix, job_no, false); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1658 | |
Alyssa Rosenzweig | 4467e79 | 2020-08-26 13:21:06 -0400 | [diff] [blame] | 1659 | /* TODO: gl_PointSize on Bifrost */ |
| 1660 | pandecode_primitive_size(t->primitive_size, true); |
| 1661 | |
| 1662 | if (t->zero1 || t->zero2 || t->zero3 || t->zero4 || t->zero5 |
| 1663 | || t->zero6) { |
| 1664 | pandecode_msg("XXX: tiler only zero tripped\n"); |
| 1665 | pandecode_prop("zero1 = 0x%" PRIx64, t->zero1); |
| 1666 | pandecode_prop("zero2 = 0x%" PRIx64, t->zero2); |
| 1667 | pandecode_prop("zero3 = 0x%" PRIx64, t->zero3); |
| 1668 | pandecode_prop("zero4 = 0x%" PRIx64, t->zero4); |
| 1669 | pandecode_prop("zero5 = 0x%" PRIx64, t->zero5); |
| 1670 | pandecode_prop("zero6 = 0x%" PRIx64, t->zero6); |
| 1671 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1672 | |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1673 | DUMP_CL(DRAW, &draw_packed, "Draw:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1674 | |
| 1675 | return sizeof(*t); |
| 1676 | } |
| 1677 | |
| 1678 | static int |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 1679 | pandecode_vertex_or_tiler_job_mdg(const struct mali_job_descriptor_header *h, |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 1680 | const struct pandecode_mapped_memory *mem, |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1681 | mali_ptr payload, int job_no, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1682 | { |
| 1683 | struct midgard_payload_vertex_tiler *PANDECODE_PTR_VAR(v, mem, payload); |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1684 | bool is_graphics = (h->job_type == MALI_JOB_TYPE_VERTEX) || (h->job_type == MALI_JOB_TYPE_TILER); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1685 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1686 | struct mali_draw_packed draw_packed; |
| 1687 | memcpy(&draw_packed, &v->postfix, sizeof(draw_packed)); |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1688 | pan_unpack(&draw_packed, DRAW, draw); |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1689 | pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->job_type, "", false, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1690 | |
Alyssa Rosenzweig | b010a6d | 2020-04-06 20:31:32 -0400 | [diff] [blame] | 1691 | pandecode_vertex_tiler_prefix(&v->prefix, job_no, is_graphics); |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1692 | DUMP_CL(DRAW, &draw_packed, "Draw:\n"); |
Alyssa Rosenzweig | b010a6d | 2020-04-06 20:31:32 -0400 | [diff] [blame] | 1693 | |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 1694 | struct mali_primitive_packed prim_packed = v->prefix.primitive; |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 1695 | pan_unpack(&prim_packed, PRIMITIVE, primitive); |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 1696 | |
| 1697 | pandecode_primitive_size(v->primitive_size, primitive.point_size_array == 0); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1698 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1699 | return sizeof(*v); |
| 1700 | } |
| 1701 | |
| 1702 | static int |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 1703 | pandecode_fragment_job(const struct pandecode_mapped_memory *mem, |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 1704 | mali_ptr payload, int job_no, |
Tomeu Vizoso | 697f02c | 2019-11-12 12:15:02 +0100 | [diff] [blame] | 1705 | bool is_bifrost, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1706 | { |
| 1707 | const struct mali_payload_fragment *PANDECODE_PTR_VAR(s, mem, payload); |
| 1708 | |
Alyssa Rosenzweig | 8959364 | 2019-12-16 12:05:45 -0500 | [diff] [blame] | 1709 | bool is_mfbd = s->framebuffer & MALI_MFBD; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1710 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1711 | if (!is_mfbd && is_bifrost) |
| 1712 | pandecode_msg("XXX: Bifrost fragment must use MFBD\n"); |
| 1713 | |
| 1714 | struct pandecode_fbd info; |
| 1715 | |
| 1716 | if (is_mfbd) |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 1717 | info = pandecode_mfbd_bfr(s->framebuffer & FBD_MASK, job_no, true, false, is_bifrost); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1718 | else |
Tomeu Vizoso | 697f02c | 2019-11-12 12:15:02 +0100 | [diff] [blame] | 1719 | info = pandecode_sfbd(s->framebuffer & FBD_MASK, job_no, true, gpu_id); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1720 | |
| 1721 | /* Compute the tag for the tagged pointer. This contains the type of |
| 1722 | * FBD (MFBD/SFBD), and in the case of an MFBD, information about which |
| 1723 | * additional structures follow the MFBD header (an extra payload or |
| 1724 | * not, as well as a count of render targets) */ |
| 1725 | |
Alyssa Rosenzweig | 8959364 | 2019-12-16 12:05:45 -0500 | [diff] [blame] | 1726 | unsigned expected_tag = is_mfbd ? MALI_MFBD : 0; |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1727 | |
| 1728 | if (is_mfbd) { |
| 1729 | if (info.has_extra) |
| 1730 | expected_tag |= MALI_MFBD_TAG_EXTRA; |
| 1731 | |
| 1732 | expected_tag |= (MALI_POSITIVE(info.rt_count) << 2); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1733 | } |
| 1734 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1735 | if ((s->min_tile_coord | s->max_tile_coord) & ~(MALI_X_COORD_MASK | MALI_Y_COORD_MASK)) { |
| 1736 | pandecode_msg("XXX: unexpected tile coordinate bits\n"); |
| 1737 | pandecode_prop("min_tile_coord = 0x%X\n", s->min_tile_coord); |
Alyssa Rosenzweig | 52d6b4d | 2020-05-11 18:54:05 -0400 | [diff] [blame] | 1738 | pandecode_prop("max_tile_coord = 0x%X\n", s->max_tile_coord); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1739 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1740 | |
Alyssa Rosenzweig | ded9a68 | 2019-08-21 12:29:47 -0700 | [diff] [blame] | 1741 | /* Extract tile coordinates */ |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1742 | |
Alyssa Rosenzweig | ded9a68 | 2019-08-21 12:29:47 -0700 | [diff] [blame] | 1743 | unsigned min_x = MALI_TILE_COORD_X(s->min_tile_coord) << MALI_TILE_SHIFT; |
| 1744 | unsigned min_y = MALI_TILE_COORD_Y(s->min_tile_coord) << MALI_TILE_SHIFT; |
| 1745 | |
| 1746 | unsigned max_x = (MALI_TILE_COORD_X(s->max_tile_coord) + 1) << MALI_TILE_SHIFT; |
| 1747 | unsigned max_y = (MALI_TILE_COORD_Y(s->max_tile_coord) + 1) << MALI_TILE_SHIFT; |
| 1748 | |
| 1749 | /* For the max, we also want the floored (rather than ceiled) version for checking */ |
| 1750 | |
| 1751 | unsigned max_x_f = (MALI_TILE_COORD_X(s->max_tile_coord)) << MALI_TILE_SHIFT; |
| 1752 | unsigned max_y_f = (MALI_TILE_COORD_Y(s->max_tile_coord)) << MALI_TILE_SHIFT; |
| 1753 | |
| 1754 | /* Validate the coordinates are well-ordered */ |
| 1755 | |
| 1756 | if (min_x == max_x) |
| 1757 | pandecode_msg("XXX: empty X coordinates (%u = %u)\n", min_x, max_x); |
| 1758 | else if (min_x > max_x) |
| 1759 | pandecode_msg("XXX: misordered X coordinates (%u > %u)\n", min_x, max_x); |
| 1760 | |
| 1761 | if (min_y == max_y) |
| 1762 | pandecode_msg("XXX: empty X coordinates (%u = %u)\n", min_x, max_x); |
| 1763 | else if (min_y > max_y) |
| 1764 | pandecode_msg("XXX: misordered X coordinates (%u > %u)\n", min_x, max_x); |
| 1765 | |
| 1766 | /* Validate the coordinates fit inside the framebuffer. We use floor, |
| 1767 | * rather than ceil, for the max coordinates, since the tile |
| 1768 | * coordinates for something like an 800x600 framebuffer will actually |
| 1769 | * resolve to 800x608, which would otherwise trigger a Y-overflow */ |
| 1770 | |
| 1771 | if ((min_x > info.width) || (max_x_f > info.width)) |
| 1772 | pandecode_msg("XXX: tile coordinates overflow in X direction\n"); |
| 1773 | |
| 1774 | if ((min_y > info.height) || (max_y_f > info.height)) |
| 1775 | pandecode_msg("XXX: tile coordinates overflow in Y direction\n"); |
| 1776 | |
| 1777 | /* After validation, we print */ |
| 1778 | |
| 1779 | 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] | 1780 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1781 | /* The FBD is a tagged pointer */ |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1782 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1783 | unsigned tag = (s->framebuffer & ~FBD_MASK); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1784 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1785 | if (tag != expected_tag) |
| 1786 | 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] | 1787 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1788 | return sizeof(*s); |
| 1789 | } |
| 1790 | |
Alyssa Rosenzweig | 4122f74 | 2020-02-18 07:43:51 -0500 | [diff] [blame] | 1791 | /* Entrypoint to start tracing. jc_gpu_va is the GPU address for the first job |
| 1792 | * in the chain; later jobs are found by walking the chain. Bifrost is, well, |
| 1793 | * if it's bifrost or not. GPU ID is the more finegrained ID (at some point, we |
| 1794 | * might wish to combine this with the bifrost parameter) because some details |
| 1795 | * are model-specific even within a particular architecture. Minimal traces |
| 1796 | * *only* examine the job descriptors, skipping printing entirely if there is |
| 1797 | * no faults, and only descends into the payload if there are faults. This is |
| 1798 | * useful for looking for faults without the overhead of invasive traces. */ |
| 1799 | |
Alyssa Rosenzweig | 5998646 | 2020-02-18 07:46:03 -0500 | [diff] [blame] | 1800 | void |
Alyssa Rosenzweig | 4122f74 | 2020-02-18 07:43:51 -0500 | [diff] [blame] | 1801 | 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] | 1802 | { |
Icecream95 | 01d60d3 | 2020-07-16 16:12:13 +1200 | [diff] [blame] | 1803 | pandecode_dump_file_open(); |
| 1804 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1805 | struct mali_job_descriptor_header *h; |
Alyssa Rosenzweig | 5998646 | 2020-02-18 07:46:03 -0500 | [diff] [blame] | 1806 | unsigned job_descriptor_number = 0; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1807 | |
| 1808 | do { |
| 1809 | struct pandecode_mapped_memory *mem = |
| 1810 | pandecode_find_mapped_gpu_mem_containing(jc_gpu_va); |
| 1811 | |
| 1812 | void *payload; |
| 1813 | |
| 1814 | h = PANDECODE_PTR(mem, jc_gpu_va, struct mali_job_descriptor_header); |
| 1815 | |
Alyssa Rosenzweig | aac5a55 | 2020-08-21 09:31:43 -0400 | [diff] [blame] | 1816 | mali_ptr payload_ptr = jc_gpu_va + sizeof(*h); |
Alyssa Rosenzweig | d353b15 | 2020-08-21 09:36:14 -0400 | [diff] [blame] | 1817 | payload = pandecode_fetch_gpu_mem(mem, payload_ptr, 64); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1818 | |
| 1819 | int job_no = job_descriptor_number++; |
| 1820 | |
Alyssa Rosenzweig | 4122f74 | 2020-02-18 07:43:51 -0500 | [diff] [blame] | 1821 | /* If the job is good to go, skip it in minimal mode */ |
| 1822 | if (minimal && (h->exception_status == 0x0 || h->exception_status == 0x1)) |
| 1823 | continue; |
| 1824 | |
Tomeu Vizoso | 9bef1f1 | 2019-06-25 09:20:51 +0200 | [diff] [blame] | 1825 | pandecode_log("struct mali_job_descriptor_header job_%"PRIx64"_%d = {\n", jc_gpu_va, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1826 | pandecode_indent++; |
| 1827 | |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1828 | pandecode_prop("job_type = %s", mali_job_type_as_str(h->job_type)); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1829 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1830 | if (h->job_descriptor_size) |
| 1831 | pandecode_prop("job_descriptor_size = %d", h->job_descriptor_size); |
| 1832 | |
Alyssa Rosenzweig | e918dd8 | 2019-08-16 16:36:39 -0700 | [diff] [blame] | 1833 | if (h->exception_status && h->exception_status != 0x1) |
Alyssa Rosenzweig | 358372b | 2019-08-09 16:04:24 -0700 | [diff] [blame] | 1834 | pandecode_prop("exception_status = %x (source ID: 0x%x access: %s exception: 0x%x)", |
Tomeu Vizoso | fa36c19 | 2019-06-25 08:22:30 +0200 | [diff] [blame] | 1835 | h->exception_status, |
| 1836 | (h->exception_status >> 16) & 0xFFFF, |
Alyssa Rosenzweig | 78445ce | 2020-08-11 21:19:52 -0400 | [diff] [blame] | 1837 | mali_exception_access_as_str((h->exception_status >> 8) & 0x3), |
Tomeu Vizoso | fa36c19 | 2019-06-25 08:22:30 +0200 | [diff] [blame] | 1838 | h->exception_status & 0xFF); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1839 | |
| 1840 | if (h->first_incomplete_task) |
| 1841 | pandecode_prop("first_incomplete_task = %d", h->first_incomplete_task); |
| 1842 | |
| 1843 | if (h->fault_pointer) |
| 1844 | pandecode_prop("fault_pointer = 0x%" PRIx64, h->fault_pointer); |
| 1845 | |
| 1846 | if (h->job_barrier) |
| 1847 | pandecode_prop("job_barrier = %d", h->job_barrier); |
| 1848 | |
| 1849 | pandecode_prop("job_index = %d", h->job_index); |
| 1850 | |
| 1851 | if (h->unknown_flags) |
| 1852 | pandecode_prop("unknown_flags = %d", h->unknown_flags); |
| 1853 | |
| 1854 | if (h->job_dependency_index_1) |
| 1855 | pandecode_prop("job_dependency_index_1 = %d", h->job_dependency_index_1); |
| 1856 | |
| 1857 | if (h->job_dependency_index_2) |
| 1858 | pandecode_prop("job_dependency_index_2 = %d", h->job_dependency_index_2); |
| 1859 | |
| 1860 | pandecode_indent--; |
| 1861 | pandecode_log("};\n"); |
| 1862 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1863 | switch (h->job_type) { |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1864 | case MALI_JOB_TYPE_WRITE_VALUE: { |
Alyssa Rosenzweig | adf716d | 2019-12-05 09:06:53 -0500 | [diff] [blame] | 1865 | struct mali_payload_write_value *s = payload; |
| 1866 | 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] | 1867 | pandecode_indent++; |
Alyssa Rosenzweig | 9eae950 | 2019-12-04 08:59:29 -0500 | [diff] [blame] | 1868 | MEMORY_PROP(s, address); |
| 1869 | |
Alyssa Rosenzweig | adf716d | 2019-12-05 09:06:53 -0500 | [diff] [blame] | 1870 | if (s->value_descriptor != MALI_WRITE_VALUE_ZERO) { |
Alyssa Rosenzweig | 9eae950 | 2019-12-04 08:59:29 -0500 | [diff] [blame] | 1871 | pandecode_msg("XXX: unknown value descriptor\n"); |
| 1872 | pandecode_prop("value_descriptor = 0x%" PRIX32, s->value_descriptor); |
| 1873 | } |
| 1874 | |
| 1875 | if (s->reserved) { |
| 1876 | pandecode_msg("XXX: set value tripped\n"); |
| 1877 | pandecode_prop("reserved = 0x%" PRIX32, s->reserved); |
| 1878 | } |
| 1879 | |
| 1880 | pandecode_prop("immediate = 0x%" PRIX64, s->immediate); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1881 | pandecode_indent--; |
| 1882 | pandecode_log("};\n"); |
| 1883 | |
| 1884 | break; |
| 1885 | } |
| 1886 | |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1887 | case MALI_JOB_TYPE_TILER: |
| 1888 | case MALI_JOB_TYPE_VERTEX: |
| 1889 | case MALI_JOB_TYPE_COMPUTE: |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1890 | if (bifrost) { |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1891 | if (h->job_type == MALI_JOB_TYPE_TILER) |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1892 | pandecode_tiler_job_bfr(h, mem, payload_ptr, job_no, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1893 | else |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1894 | pandecode_vertex_job_bfr(h, mem, payload_ptr, job_no, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1895 | } else |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 1896 | 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] | 1897 | |
| 1898 | break; |
| 1899 | |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1900 | case MALI_JOB_TYPE_FRAGMENT: |
Tomeu Vizoso | 697f02c | 2019-11-12 12:15:02 +0100 | [diff] [blame] | 1901 | pandecode_fragment_job(mem, payload_ptr, job_no, bifrost, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1902 | break; |
| 1903 | |
| 1904 | default: |
| 1905 | break; |
| 1906 | } |
Alyssa Rosenzweig | 65e5c19 | 2019-12-27 13:03:22 -0500 | [diff] [blame] | 1907 | } while ((jc_gpu_va = h->next_job)); |
Icecream95 | ef67218 | 2020-06-22 22:49:53 +1200 | [diff] [blame] | 1908 | |
| 1909 | pandecode_map_read_write(); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1910 | } |