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