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 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 42 | #define MEMORY_PROP(obj, p) {\ |
Alyssa Rosenzweig | 2608da1 | 2019-06-19 09:35:57 -0700 | [diff] [blame] | 43 | if (obj->p) { \ |
| 44 | char *a = pointer_as_memory_reference(obj->p); \ |
| 45 | pandecode_prop("%s = %s", #p, a); \ |
| 46 | free(a); \ |
| 47 | } \ |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 48 | } |
| 49 | |
Alyssa Rosenzweig | 0c1874a | 2019-07-12 08:47:35 -0700 | [diff] [blame] | 50 | #define MEMORY_PROP_DIR(obj, p) {\ |
| 51 | if (obj.p) { \ |
| 52 | char *a = pointer_as_memory_reference(obj.p); \ |
| 53 | pandecode_prop("%s = %s", #p, a); \ |
| 54 | free(a); \ |
| 55 | } \ |
| 56 | } |
| 57 | |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 58 | #define DUMP_UNPACKED(T, var, ...) { \ |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 59 | pandecode_log(__VA_ARGS__); \ |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 60 | pan_print(pandecode_dump_stream, T, var, (pandecode_indent + 1) * 2); \ |
| 61 | } |
| 62 | |
| 63 | #define DUMP_CL(T, cl, ...) {\ |
Boris Brezillon | 62c0ef0 | 2020-09-05 18:04:43 +0200 | [diff] [blame] | 64 | pan_unpack(cl, T, temp); \ |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 65 | DUMP_UNPACKED(T, temp, __VA_ARGS__); \ |
Alyssa Rosenzweig | d2ddd4d | 2020-08-05 19:43:58 -0400 | [diff] [blame] | 66 | } |
| 67 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 68 | #define DUMP_SECTION(A, S, cl, ...) { \ |
| 69 | pan_section_unpack(cl, A, S, temp); \ |
| 70 | pandecode_log(__VA_ARGS__); \ |
| 71 | pan_section_print(pandecode_dump_stream, A, S, temp, (pandecode_indent + 1) * 2); \ |
| 72 | } |
| 73 | |
Alyssa Rosenzweig | 4e3fe54 | 2020-08-14 16:03:12 -0400 | [diff] [blame] | 74 | #define MAP_ADDR(T, addr, cl) \ |
| 75 | const uint8_t *cl = 0; \ |
| 76 | { \ |
| 77 | struct pandecode_mapped_memory *mapped_mem = pandecode_find_mapped_gpu_mem_containing(addr); \ |
| 78 | cl = pandecode_fetch_gpu_mem(mapped_mem, addr, MALI_ ## T ## _LENGTH); \ |
| 79 | } |
| 80 | |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 81 | #define DUMP_ADDR(T, addr, ...) {\ |
Alyssa Rosenzweig | 4e3fe54 | 2020-08-14 16:03:12 -0400 | [diff] [blame] | 82 | MAP_ADDR(T, addr, cl) \ |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 83 | DUMP_CL(T, cl, __VA_ARGS__); \ |
Alyssa Rosenzweig | d2ddd4d | 2020-08-05 19:43:58 -0400 | [diff] [blame] | 84 | } |
| 85 | |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 86 | FILE *pandecode_dump_stream; |
| 87 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 88 | /* Semantic logging type. |
| 89 | * |
| 90 | * Raw: for raw messages to be printed as is. |
| 91 | * Message: for helpful information to be commented out in replays. |
| 92 | * Property: for properties of a struct |
| 93 | * |
| 94 | * Use one of pandecode_log, pandecode_msg, or pandecode_prop as syntax sugar. |
| 95 | */ |
| 96 | |
| 97 | enum pandecode_log_type { |
| 98 | PANDECODE_RAW, |
| 99 | PANDECODE_MESSAGE, |
| 100 | PANDECODE_PROPERTY |
| 101 | }; |
| 102 | |
| 103 | #define pandecode_log(...) pandecode_log_typed(PANDECODE_RAW, __VA_ARGS__) |
| 104 | #define pandecode_msg(...) pandecode_log_typed(PANDECODE_MESSAGE, __VA_ARGS__) |
| 105 | #define pandecode_prop(...) pandecode_log_typed(PANDECODE_PROPERTY, __VA_ARGS__) |
| 106 | |
| 107 | unsigned pandecode_indent = 0; |
| 108 | |
| 109 | static void |
| 110 | pandecode_make_indent(void) |
| 111 | { |
| 112 | for (unsigned i = 0; i < pandecode_indent; ++i) |
Boris Brezillon | 6249ae7 | 2020-09-09 17:52:23 +0200 | [diff] [blame] | 113 | fprintf(pandecode_dump_stream, " "); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 114 | } |
| 115 | |
Boris Brezillon | f9977f8 | 2020-09-29 10:25:56 +0200 | [diff] [blame] | 116 | static void PRINTFLIKE(2, 3) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 117 | pandecode_log_typed(enum pandecode_log_type type, const char *format, ...) |
| 118 | { |
| 119 | va_list ap; |
| 120 | |
| 121 | pandecode_make_indent(); |
| 122 | |
| 123 | if (type == PANDECODE_MESSAGE) |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 124 | fprintf(pandecode_dump_stream, "// "); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 125 | else if (type == PANDECODE_PROPERTY) |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 126 | fprintf(pandecode_dump_stream, "."); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 127 | |
| 128 | va_start(ap, format); |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 129 | vfprintf(pandecode_dump_stream, format, ap); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 130 | va_end(ap); |
| 131 | |
| 132 | if (type == PANDECODE_PROPERTY) |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 133 | fprintf(pandecode_dump_stream, ",\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | static void |
| 137 | pandecode_log_cont(const char *format, ...) |
| 138 | { |
| 139 | va_list ap; |
| 140 | |
| 141 | va_start(ap, format); |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 142 | vfprintf(pandecode_dump_stream, format, ap); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 143 | va_end(ap); |
| 144 | } |
| 145 | |
Alyssa Rosenzweig | 4391c65 | 2019-08-19 15:14:48 -0700 | [diff] [blame] | 146 | /* To check for memory safety issues, validates that the given pointer in GPU |
| 147 | * memory is valid, containing at least sz bytes. The goal is to eliminate |
| 148 | * GPU-side memory bugs (NULL pointer dereferences, buffer overflows, or buffer |
| 149 | * overruns) by statically validating pointers. |
| 150 | */ |
| 151 | |
| 152 | static void |
| 153 | pandecode_validate_buffer(mali_ptr addr, size_t sz) |
| 154 | { |
| 155 | if (!addr) { |
| 156 | pandecode_msg("XXX: null pointer deref"); |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | /* Find a BO */ |
| 161 | |
| 162 | struct pandecode_mapped_memory *bo = |
| 163 | pandecode_find_mapped_gpu_mem_containing(addr); |
| 164 | |
| 165 | if (!bo) { |
| 166 | pandecode_msg("XXX: invalid memory dereference\n"); |
| 167 | return; |
| 168 | } |
| 169 | |
| 170 | /* Bounds check */ |
| 171 | |
| 172 | unsigned offset = addr - bo->gpu_va; |
| 173 | unsigned total = offset + sz; |
| 174 | |
| 175 | if (total > bo->length) { |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 176 | pandecode_msg("XXX: buffer overrun. " |
Alyssa Rosenzweig | bcfcb7e | 2019-08-30 17:02:43 -0700 | [diff] [blame] | 177 | "Chunk of size %zu at offset %d in buffer of size %zu. " |
| 178 | "Overrun by %zu bytes. \n", |
Alyssa Rosenzweig | 4391c65 | 2019-08-19 15:14:48 -0700 | [diff] [blame] | 179 | sz, offset, bo->length, total - bo->length); |
| 180 | return; |
| 181 | } |
| 182 | } |
| 183 | |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 184 | /* Midgard's tiler descriptor is embedded within the |
| 185 | * larger FBD */ |
| 186 | |
| 187 | static void |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 188 | pandecode_midgard_tiler_descriptor( |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 189 | const struct mali_midgard_tiler_packed *tp, |
| 190 | const struct mali_midgard_tiler_weights_packed *wp, |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 191 | unsigned width, |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 192 | unsigned height, |
Alyssa Rosenzweig | 9fb0904 | 2019-11-27 08:31:16 -0500 | [diff] [blame] | 193 | bool is_fragment, |
| 194 | bool has_hierarchy) |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 195 | { |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 196 | pan_unpack(tp, MIDGARD_TILER, t); |
| 197 | DUMP_UNPACKED(MIDGARD_TILER, t, "Tiler:\n"); |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 198 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 199 | MEMORY_PROP_DIR(t, polygon_list); |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 200 | |
Alyssa Rosenzweig | 52101e4 | 2019-08-19 10:38:25 -0700 | [diff] [blame] | 201 | /* The body is offset from the base of the polygon list */ |
Alyssa Rosenzweig | b010a6d | 2020-04-06 20:31:32 -0400 | [diff] [blame] | 202 | //assert(t->polygon_list_body > t->polygon_list); |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 203 | unsigned body_offset = t.polygon_list_body - t.polygon_list; |
Alyssa Rosenzweig | 52101e4 | 2019-08-19 10:38:25 -0700 | [diff] [blame] | 204 | |
| 205 | /* It needs to fit inside the reported size */ |
Alyssa Rosenzweig | b010a6d | 2020-04-06 20:31:32 -0400 | [diff] [blame] | 206 | //assert(t->polygon_list_size >= body_offset); |
Alyssa Rosenzweig | 52101e4 | 2019-08-19 10:38:25 -0700 | [diff] [blame] | 207 | |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 208 | /* Now that we've sanity checked, we'll try to calculate the sizes |
| 209 | * ourselves for comparison */ |
| 210 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 211 | unsigned ref_header = panfrost_tiler_header_size(width, height, t.hierarchy_mask, has_hierarchy); |
| 212 | 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] | 213 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 214 | if (!((ref_header == body_offset) && (ref_size == t.polygon_list_size))) { |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 215 | pandecode_msg("XXX: bad polygon list size (expected %d / 0x%x)\n", |
| 216 | ref_header, ref_size); |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 217 | pandecode_prop("polygon_list_size = 0x%x", t.polygon_list_size); |
Alyssa Rosenzweig | a8bd3ad | 2019-08-19 11:48:32 -0700 | [diff] [blame] | 218 | pandecode_msg("body offset %d\n", body_offset); |
| 219 | } |
Alyssa Rosenzweig | 52101e4 | 2019-08-19 10:38:25 -0700 | [diff] [blame] | 220 | |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 221 | /* The tiler heap has a start and end specified -- it should be |
| 222 | * identical to what we have in the BO. The exception is if tiling is |
| 223 | * disabled. */ |
Alyssa Rosenzweig | 13d0797 | 2019-08-19 10:56:23 -0700 | [diff] [blame] | 224 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 225 | MEMORY_PROP_DIR(t, heap_start); |
| 226 | assert(t.heap_end >= t.heap_start); |
Alyssa Rosenzweig | 13d0797 | 2019-08-19 10:56:23 -0700 | [diff] [blame] | 227 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 228 | unsigned heap_size = t.heap_end - t.heap_start; |
Alyssa Rosenzweig | 13d0797 | 2019-08-19 10:56:23 -0700 | [diff] [blame] | 229 | |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 230 | /* Tiling is enabled with a special flag */ |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 231 | unsigned hierarchy_mask = t.hierarchy_mask & MALI_MIDGARD_TILER_HIERARCHY_MASK; |
| 232 | unsigned tiler_flags = t.hierarchy_mask ^ hierarchy_mask; |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 233 | |
| 234 | bool tiling_enabled = hierarchy_mask; |
| 235 | |
| 236 | if (tiling_enabled) { |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 237 | /* We should also have no other flags */ |
| 238 | if (tiler_flags) |
| 239 | pandecode_msg("XXX: unexpected tiler %X\n", tiler_flags); |
| 240 | } else { |
| 241 | /* When tiling is disabled, we should have that flag and no others */ |
| 242 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 243 | if (tiler_flags != MALI_MIDGARD_TILER_DISABLED) { |
| 244 | pandecode_msg("XXX: unexpected tiler flag %X, expected MALI_MIDGARD_TILER_DISABLED\n", |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 245 | tiler_flags); |
| 246 | } |
| 247 | |
| 248 | /* We should also have an empty heap */ |
| 249 | if (heap_size) { |
| 250 | pandecode_msg("XXX: tiler heap size %d given, expected empty\n", |
| 251 | heap_size); |
| 252 | } |
| 253 | |
| 254 | /* Disabled tiling is used only for clear-only jobs, which are |
| 255 | * purely FRAGMENT, so we should never see this for |
| 256 | * non-FRAGMENT descriptors. */ |
| 257 | |
| 258 | if (!is_fragment) |
| 259 | pandecode_msg("XXX: tiler disabled for non-FRAGMENT job\n"); |
| 260 | } |
| 261 | |
| 262 | /* We've never seen weights used in practice, but we know from the |
| 263 | * kernel these fields is there */ |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 264 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 265 | pan_unpack(wp, MIDGARD_TILER_WEIGHTS, w); |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 266 | bool nonzero_weights = false; |
| 267 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 268 | nonzero_weights |= w.weight0 != 0x0; |
| 269 | nonzero_weights |= w.weight1 != 0x0; |
| 270 | nonzero_weights |= w.weight2 != 0x0; |
| 271 | nonzero_weights |= w.weight3 != 0x0; |
| 272 | nonzero_weights |= w.weight4 != 0x0; |
| 273 | nonzero_weights |= w.weight5 != 0x0; |
| 274 | nonzero_weights |= w.weight6 != 0x0; |
| 275 | nonzero_weights |= w.weight7 != 0x0; |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 276 | |
Boris Brezillon | e855698 | 2020-09-05 18:16:37 +0200 | [diff] [blame] | 277 | if (nonzero_weights) |
| 278 | DUMP_UNPACKED(MIDGARD_TILER_WEIGHTS, w, "Tiler Weights:\n"); |
Alyssa Rosenzweig | 31fc52a | 2019-07-10 07:22:19 -0700 | [diff] [blame] | 279 | } |
| 280 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 281 | /* Information about the framebuffer passed back for |
| 282 | * additional analysis */ |
| 283 | |
| 284 | struct pandecode_fbd { |
| 285 | unsigned width; |
| 286 | unsigned height; |
| 287 | unsigned rt_count; |
| 288 | bool has_extra; |
| 289 | }; |
| 290 | |
| 291 | static struct pandecode_fbd |
Tomeu Vizoso | 697f02c | 2019-11-12 12:15:02 +0100 | [diff] [blame] | 292 | 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] | 293 | { |
| 294 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 295 | const void *PANDECODE_PTR_VAR(s, mem, (mali_ptr) gpu_va); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 296 | |
Alyssa Rosenzweig | d6d6d63 | 2019-08-30 17:00:09 -0700 | [diff] [blame] | 297 | struct pandecode_fbd info = { |
| 298 | .has_extra = false, |
| 299 | .rt_count = 1 |
| 300 | }; |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 301 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 302 | pandecode_log("Single-Target Framebuffer:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 303 | pandecode_indent++; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 304 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 305 | DUMP_SECTION(SINGLE_TARGET_FRAMEBUFFER, LOCAL_STORAGE, s, "Local Storage:\n"); |
| 306 | pan_section_unpack(s, SINGLE_TARGET_FRAMEBUFFER, PARAMETERS, p); |
| 307 | DUMP_UNPACKED(SINGLE_TARGET_FRAMEBUFFER_PARAMETERS, p, "Parameters:\n"); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 308 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 309 | const void *t = pan_section_ptr(s, SINGLE_TARGET_FRAMEBUFFER, TILER); |
| 310 | const void *w = pan_section_ptr(s, SINGLE_TARGET_FRAMEBUFFER, TILER_WEIGHTS); |
Alyssa Rosenzweig | 9fb0904 | 2019-11-27 08:31:16 -0500 | [diff] [blame] | 311 | |
| 312 | bool has_hierarchy = !(gpu_id == 0x0720 || gpu_id == 0x0820 || gpu_id == 0x0830); |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 313 | pandecode_midgard_tiler_descriptor(t, w, p.bound_max_x + 1, p.bound_max_y + 1, is_fragment, has_hierarchy); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 314 | |
| 315 | pandecode_indent--; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 316 | |
Boris Brezillon | 95eb7d9 | 2020-09-06 11:01:09 +0200 | [diff] [blame] | 317 | /* Dummy unpack of the padding section to make sure all words are 0. |
| 318 | * No need to call print here since the section is supposed to be empty. |
| 319 | */ |
| 320 | pan_section_unpack(s, SINGLE_TARGET_FRAMEBUFFER, PADDING_1, padding1); |
| 321 | pan_section_unpack(s, SINGLE_TARGET_FRAMEBUFFER, PADDING_2, padding2); |
| 322 | pandecode_log("\n"); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 323 | |
| 324 | return info; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 325 | } |
| 326 | |
| 327 | static void |
Alyssa Rosenzweig | 0aa5d89 | 2019-06-19 08:41:51 -0700 | [diff] [blame] | 328 | pandecode_compute_fbd(uint64_t gpu_va, int job_no) |
| 329 | { |
| 330 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); |
Boris Brezillon | 3a06fc3 | 2020-09-03 09:18:09 +0200 | [diff] [blame] | 331 | const struct mali_local_storage_packed *PANDECODE_PTR_VAR(s, mem, (mali_ptr) gpu_va); |
| 332 | DUMP_CL(LOCAL_STORAGE, s, "Local Storage:\n"); |
Alyssa Rosenzweig | 0aa5d89 | 2019-06-19 08:41:51 -0700 | [diff] [blame] | 333 | } |
| 334 | |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 335 | static void |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 336 | pandecode_render_target(uint64_t gpu_va, unsigned job_no, bool is_bifrost, unsigned gpu_id, |
| 337 | const struct MALI_MULTI_TARGET_FRAMEBUFFER_PARAMETERS *fb) |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 338 | { |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 339 | pandecode_log("Color Render Targets:\n"); |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 340 | pandecode_indent++; |
| 341 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 342 | for (int i = 0; i < (fb->render_target_count); i++) { |
| 343 | mali_ptr rt_va = gpu_va + i * MALI_RENDER_TARGET_LENGTH; |
| 344 | struct pandecode_mapped_memory *mem = |
| 345 | pandecode_find_mapped_gpu_mem_containing(rt_va); |
| 346 | const struct mali_render_target_packed *PANDECODE_PTR_VAR(rtp, mem, (mali_ptr) rt_va); |
| 347 | DUMP_CL(RENDER_TARGET, rtp, "Color Render Target %d:\n", i); |
Alyssa Rosenzweig | e49204c | 2019-08-20 11:11:46 -0700 | [diff] [blame] | 348 | } |
Alyssa Rosenzweig | b78e04c | 2019-08-14 16:01:38 -0700 | [diff] [blame] | 349 | |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 350 | pandecode_indent--; |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 351 | pandecode_log("\n"); |
Alyssa Rosenzweig | f943047 | 2019-02-24 06:22:23 +0000 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | static void |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 355 | pandecode_mfbd_bifrost_deps(const void *fb, int job_no) |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 356 | { |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 357 | pan_section_unpack(fb, MULTI_TARGET_FRAMEBUFFER, BIFROST_PARAMETERS, params); |
| 358 | |
| 359 | /* The blob stores all possible sample locations in a single buffer |
| 360 | * allocated on startup, and just switches the pointer when switching |
| 361 | * MSAA state. For now, we just put the data into the cmdstream, but we |
| 362 | * should do something like what the blob does with a real driver. |
| 363 | * |
| 364 | * There seem to be 32 slots for sample locations, followed by another |
| 365 | * 16. The second 16 is just the center location followed by 15 zeros |
| 366 | * in all the cases I've identified (maybe shader vs. depth/color |
| 367 | * samples?). |
| 368 | */ |
| 369 | |
| 370 | struct pandecode_mapped_memory *smem = |
| 371 | pandecode_find_mapped_gpu_mem_containing(params.sample_locations); |
| 372 | |
| 373 | const u16 *PANDECODE_PTR_VAR(samples, smem, params.sample_locations); |
| 374 | |
| 375 | pandecode_log("uint16_t sample_locations_%d[] = {\n", job_no); |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 376 | pandecode_indent++; |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 377 | for (int i = 0; i < 32 + 16; i++) { |
| 378 | pandecode_log("%d, %d,\n", samples[2 * i], samples[2 * i + 1]); |
Alyssa Rosenzweig | 8c88bd0 | 2019-06-11 14:56:30 -0700 | [diff] [blame] | 379 | } |
| 380 | |
| 381 | pandecode_indent--; |
| 382 | pandecode_log("};\n"); |
| 383 | } |
| 384 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 385 | static struct pandecode_fbd |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 386 | pandecode_mfbd_bfr(uint64_t gpu_va, int job_no, bool is_fragment, bool is_compute, bool is_bifrost, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 387 | { |
| 388 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 389 | const void *PANDECODE_PTR_VAR(fb, mem, (mali_ptr) gpu_va); |
| 390 | pan_section_unpack(fb, MULTI_TARGET_FRAMEBUFFER, PARAMETERS, params); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 391 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 392 | struct pandecode_fbd info; |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 393 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 394 | if (is_bifrost) |
| 395 | pandecode_mfbd_bifrost_deps(fb, job_no); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 396 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 397 | pandecode_log("Multi-Target Framebuffer:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 398 | pandecode_indent++; |
| 399 | |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 400 | if (is_bifrost) { |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 401 | DUMP_SECTION(MULTI_TARGET_FRAMEBUFFER, BIFROST_PARAMETERS, fb, "Bifrost Params:\n"); |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 402 | } else { |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 403 | DUMP_SECTION(MULTI_TARGET_FRAMEBUFFER, LOCAL_STORAGE, fb, "Local Storage:\n"); |
Alyssa Rosenzweig | 3f5cd44 | 2020-02-28 07:17:53 -0500 | [diff] [blame] | 404 | } |
Alyssa Rosenzweig | 85e745f | 2019-06-12 09:33:06 -0700 | [diff] [blame] | 405 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 406 | info.width = params.width; |
| 407 | info.height = params.height; |
| 408 | info.rt_count = params.render_target_count; |
| 409 | DUMP_UNPACKED(MULTI_TARGET_FRAMEBUFFER_PARAMETERS, params, "Parameters:\n"); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 410 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 411 | if (!is_compute) { |
| 412 | if (is_bifrost) { |
| 413 | DUMP_SECTION(MULTI_TARGET_FRAMEBUFFER, BIFROST_TILER_POINTER, fb, "Tiler Pointer"); |
| 414 | } else { |
| 415 | const void *t = pan_section_ptr(fb, MULTI_TARGET_FRAMEBUFFER, TILER); |
| 416 | const void *w = pan_section_ptr(fb, MULTI_TARGET_FRAMEBUFFER, TILER_WEIGHTS); |
| 417 | pandecode_midgard_tiler_descriptor(t, w, params.width, params.height, is_fragment, true); |
Alyssa Rosenzweig | c2c8b1a | 2020-05-26 18:10:39 -0400 | [diff] [blame] | 418 | } |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 419 | } else { |
Alyssa Rosenzweig | 3993969 | 2020-01-22 08:51:19 -0500 | [diff] [blame] | 420 | pandecode_msg("XXX: skipping compute MFBD, fixme\n"); |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 421 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 422 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 423 | if (is_bifrost) { |
| 424 | pan_section_unpack(fb, MULTI_TARGET_FRAMEBUFFER, BIFROST_PADDING, padding); |
Alyssa Rosenzweig | 85e745f | 2019-06-12 09:33:06 -0700 | [diff] [blame] | 425 | } |
| 426 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 427 | pandecode_indent--; |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 428 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 429 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 430 | gpu_va += MALI_MULTI_TARGET_FRAMEBUFFER_LENGTH; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 431 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 432 | info.has_extra = params.has_zs_crc_extension; |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 433 | |
| 434 | if (info.has_extra) { |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 435 | struct pandecode_mapped_memory *mem = |
| 436 | pandecode_find_mapped_gpu_mem_containing(gpu_va); |
| 437 | const struct mali_zs_crc_extension_packed *PANDECODE_PTR_VAR(zs_crc, mem, (mali_ptr)gpu_va); |
| 438 | DUMP_CL(ZS_CRC_EXTENSION, zs_crc, "ZS CRC Extension:\n"); |
| 439 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 440 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 441 | gpu_va += MALI_ZS_CRC_EXTENSION_LENGTH; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 442 | } |
| 443 | |
Alyssa Rosenzweig | 897110a | 2019-08-19 14:47:50 -0700 | [diff] [blame] | 444 | if (is_fragment) |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 445 | pandecode_render_target(gpu_va, job_no, is_bifrost, gpu_id, ¶ms); |
Alyssa Rosenzweig | a9fc1c8 | 2019-06-23 11:29:46 -0700 | [diff] [blame] | 446 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 447 | return info; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | static void |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 451 | pandecode_attributes(const struct pandecode_mapped_memory *mem, |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 452 | mali_ptr addr, int job_no, char *suffix, |
Alyssa Rosenzweig | f4678f3 | 2019-08-22 13:27:38 -0700 | [diff] [blame] | 453 | int count, bool varying, enum mali_job_type job_type) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 454 | { |
Alyssa Rosenzweig | 4e3fe54 | 2020-08-14 16:03:12 -0400 | [diff] [blame] | 455 | char *prefix = varying ? "Varying" : "Attribute"; |
Alyssa Rosenzweig | ed464e0 | 2019-08-22 13:07:01 -0700 | [diff] [blame] | 456 | assert(addr); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 457 | |
Alyssa Rosenzweig | ed464e0 | 2019-08-22 13:07:01 -0700 | [diff] [blame] | 458 | if (!count) { |
| 459 | pandecode_msg("warn: No %s records\n", prefix); |
Alyssa Rosenzweig | 5ad8301 | 2019-08-08 09:23:29 -0700 | [diff] [blame] | 460 | return; |
| 461 | } |
| 462 | |
Alyssa Rosenzweig | 4e3fe54 | 2020-08-14 16:03:12 -0400 | [diff] [blame] | 463 | MAP_ADDR(ATTRIBUTE_BUFFER, addr, cl); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 464 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 465 | for (int i = 0; i < count; ++i) { |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 466 | pan_unpack(cl + i * MALI_ATTRIBUTE_BUFFER_LENGTH, ATTRIBUTE_BUFFER, temp); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 467 | DUMP_UNPACKED(ATTRIBUTE_BUFFER, temp, "%s:\n", prefix); |
Alyssa Rosenzweig | f4678f3 | 2019-08-22 13:27:38 -0700 | [diff] [blame] | 468 | |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 469 | if (temp.type != MALI_ATTRIBUTE_TYPE_1D_NPOT_DIVISOR) |
| 470 | continue; |
| 471 | |
| 472 | pan_unpack(cl + (i + 1) * MALI_ATTRIBUTE_BUFFER_LENGTH, |
| 473 | ATTRIBUTE_BUFFER_CONTINUATION_NPOT, temp2); |
| 474 | pan_print(pandecode_dump_stream, ATTRIBUTE_BUFFER_CONTINUATION_NPOT, |
| 475 | temp2, (pandecode_indent + 1) * 2); |
Alyssa Rosenzweig | 3b3d965 | 2019-12-19 12:28:42 -0500 | [diff] [blame] | 476 | } |
Boris Brezillon | b1c3f63 | 2020-09-10 12:46:33 +0200 | [diff] [blame] | 477 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | static mali_ptr |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 481 | pandecode_shader_address(const char *name, mali_ptr ptr) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 482 | { |
| 483 | /* TODO: Decode flags */ |
| 484 | mali_ptr shader_ptr = ptr & ~15; |
| 485 | |
| 486 | char *a = pointer_as_memory_reference(shader_ptr); |
| 487 | pandecode_prop("%s = (%s) | %d", name, a, (int) (ptr & 15)); |
| 488 | free(a); |
| 489 | |
| 490 | return shader_ptr; |
| 491 | } |
| 492 | |
Alyssa Rosenzweig | ae70538 | 2019-05-18 20:48:43 +0000 | [diff] [blame] | 493 | /* Decodes a Bifrost blend constant. See the notes in bifrost_blend_rt */ |
| 494 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 495 | static mali_ptr |
Boris Brezillon | 8389976 | 2020-09-16 13:31:37 +0200 | [diff] [blame] | 496 | pandecode_bifrost_blend(void *descs, int job_no, int rt_no, mali_ptr frag_shader) |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 497 | { |
Boris Brezillon | 8389976 | 2020-09-16 13:31:37 +0200 | [diff] [blame] | 498 | pan_unpack(descs + (rt_no * MALI_BLEND_LENGTH), BLEND, b); |
| 499 | DUMP_UNPACKED(BLEND, b, "Blend RT %d:\n", rt_no); |
Boris Brezillon | 8d707cd | 2020-10-12 14:16:53 +0200 | [diff] [blame] | 500 | if (b.bifrost.internal.mode != MALI_BIFROST_BLEND_MODE_SHADER) |
Alyssa Rosenzweig | b6d46d0 | 2019-06-19 09:31:16 -0700 | [diff] [blame] | 501 | return 0; |
| 502 | |
Boris Brezillon | 8d707cd | 2020-10-12 14:16:53 +0200 | [diff] [blame] | 503 | return (frag_shader & 0xFFFFFFFF00000000ULL) | b.bifrost.internal.shader.pc; |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | static mali_ptr |
| 507 | pandecode_midgard_blend_mrt(void *descs, int job_no, int rt_no) |
| 508 | { |
Boris Brezillon | 8389976 | 2020-09-16 13:31:37 +0200 | [diff] [blame] | 509 | pan_unpack(descs + (rt_no * MALI_BLEND_LENGTH), BLEND, b); |
| 510 | DUMP_UNPACKED(BLEND, b, "Blend RT %d:\n", rt_no); |
| 511 | return b.midgard.blend_shader ? (b.midgard.shader_pc & ~0xf) : 0; |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 512 | } |
| 513 | |
Alyssa Rosenzweig | 2208eb9 | 2019-08-20 13:59:26 -0700 | [diff] [blame] | 514 | /* Attributes and varyings have descriptor records, which contain information |
| 515 | * about their format and ordering with the attribute/varying buffers. We'll |
| 516 | * want to validate that the combinations specified are self-consistent. |
| 517 | */ |
| 518 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 519 | static int |
Alyssa Rosenzweig | 6855228 | 2020-08-26 16:50:16 -0400 | [diff] [blame] | 520 | pandecode_attribute_meta(int count, mali_ptr attribute, bool varying, char *suffix) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 521 | { |
Alyssa Rosenzweig | 6855228 | 2020-08-26 16:50:16 -0400 | [diff] [blame] | 522 | for (int i = 0; i < count; ++i, attribute += MALI_ATTRIBUTE_LENGTH) |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 523 | DUMP_ADDR(ATTRIBUTE, attribute, "%s:\n", varying ? "Varying" : "Attribute"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 524 | |
Boris Brezillon | b1c3f63 | 2020-09-10 12:46:33 +0200 | [diff] [blame] | 525 | pandecode_log("\n"); |
Alyssa Rosenzweig | 2c8a722 | 2020-08-13 13:27:16 -0400 | [diff] [blame] | 526 | return count; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 527 | } |
| 528 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 529 | /* return bits [lo, hi) of word */ |
| 530 | static u32 |
| 531 | bits(u32 word, u32 lo, u32 hi) |
| 532 | { |
| 533 | if (hi - lo >= 32) |
| 534 | return word; // avoid undefined behavior with the shift |
| 535 | |
| 536 | return (word >> lo) & ((1 << (hi - lo)) - 1); |
| 537 | } |
| 538 | |
| 539 | static void |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 540 | pandecode_invocation(const void *i, bool graphics) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 541 | { |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 542 | /* Decode invocation_count. See the comment before the definition of |
| 543 | * invocation_count for an explanation. |
| 544 | */ |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 545 | pan_unpack(i, INVOCATION, invocation); |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 546 | |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 547 | unsigned size_x = bits(invocation.invocations, 0, invocation.size_y_shift) + 1; |
| 548 | unsigned size_y = bits(invocation.invocations, invocation.size_y_shift, invocation.size_z_shift) + 1; |
| 549 | 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] | 550 | |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 551 | unsigned groups_x = bits(invocation.invocations, invocation.workgroups_x_shift, invocation.workgroups_y_shift) + 1; |
| 552 | unsigned groups_y = bits(invocation.invocations, invocation.workgroups_y_shift, invocation.workgroups_z_shift) + 1; |
| 553 | unsigned groups_z = bits(invocation.invocations, invocation.workgroups_z_shift, 32) + 1; |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 554 | |
| 555 | /* Even though we have this decoded, we want to ensure that the |
| 556 | * representation is "unique" so we don't lose anything by printing only |
| 557 | * the final result. More specifically, we need to check that we were |
| 558 | * passed something in canonical form, since the definition per the |
| 559 | * hardware is inherently not unique. How? Well, take the resulting |
| 560 | * decode and pack it ourselves! If it is bit exact with what we |
| 561 | * decoded, we're good to go. */ |
| 562 | |
Alyssa Rosenzweig | 02e768e | 2020-08-26 13:04:17 -0400 | [diff] [blame] | 563 | struct mali_invocation_packed ref; |
Alyssa Rosenzweig | 385a4f7 | 2019-12-24 22:33:47 -0500 | [diff] [blame] | 564 | 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] | 565 | |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 566 | if (memcmp(&ref, i, sizeof(ref))) { |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 567 | pandecode_msg("XXX: non-canonical workgroups packing\n"); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 568 | DUMP_UNPACKED(INVOCATION, invocation, "Invocation:\n") |
Alyssa Rosenzweig | 25ed930 | 2019-08-16 16:22:38 -0700 | [diff] [blame] | 569 | } |
| 570 | |
| 571 | /* Regardless, print the decode */ |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 572 | pandecode_log("Invocation (%d, %d, %d) x (%d, %d, %d)\n", |
| 573 | size_x, size_y, size_z, |
| 574 | groups_x, groups_y, groups_z); |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 575 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 576 | |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 577 | static void |
| 578 | pandecode_primitive(const void *p) |
| 579 | { |
| 580 | pan_unpack(p, PRIMITIVE, primitive); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 581 | DUMP_UNPACKED(PRIMITIVE, primitive, "Primitive:\n"); |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 582 | |
| 583 | /* Validate an index buffer is present if we need one. TODO: verify |
| 584 | * relationship between invocation_count and index_count */ |
| 585 | |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 586 | if (primitive.indices) { |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 587 | /* Grab the size */ |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 588 | unsigned size = (primitive.index_type == MALI_INDEX_TYPE_UINT32) ? |
| 589 | sizeof(uint32_t) : primitive.index_type; |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 590 | |
| 591 | /* Ensure we got a size, and if so, validate the index buffer |
| 592 | * is large enough to hold a full set of indices of the given |
| 593 | * size */ |
| 594 | |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 595 | if (!size) |
Alyssa Rosenzweig | f38ce6e | 2019-08-21 16:06:23 -0700 | [diff] [blame] | 596 | pandecode_msg("XXX: index size missing\n"); |
| 597 | else |
Alyssa Rosenzweig | b60d567 | 2020-08-25 16:59:14 -0400 | [diff] [blame] | 598 | pandecode_validate_buffer(primitive.indices, primitive.index_count * size); |
| 599 | } else if (primitive.index_type) |
| 600 | pandecode_msg("XXX: unexpected index size\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 601 | } |
| 602 | |
| 603 | static void |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 604 | pandecode_uniform_buffers(mali_ptr pubufs, int ubufs_count, int job_no) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 605 | { |
| 606 | struct pandecode_mapped_memory *umem = pandecode_find_mapped_gpu_mem_containing(pubufs); |
Alyssa Rosenzweig | 7d3c48f | 2020-02-16 17:01:02 -0500 | [diff] [blame] | 607 | uint64_t *PANDECODE_PTR_VAR(ubufs, umem, pubufs); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 608 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 609 | for (int i = 0; i < ubufs_count; i++) { |
Alyssa Rosenzweig | 7d3c48f | 2020-02-16 17:01:02 -0500 | [diff] [blame] | 610 | unsigned size = (ubufs[i] & ((1 << 10) - 1)) * 16; |
| 611 | mali_ptr addr = (ubufs[i] >> 10) << 2; |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 612 | |
| 613 | pandecode_validate_buffer(addr, size); |
| 614 | |
Alyssa Rosenzweig | 7d3c48f | 2020-02-16 17:01:02 -0500 | [diff] [blame] | 615 | char *ptr = pointer_as_memory_reference(addr); |
Alyssa Rosenzweig | 6ec33b4 | 2019-08-21 11:46:06 -0700 | [diff] [blame] | 616 | pandecode_log("ubuf_%d[%u] = %s;\n", i, size, ptr); |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 617 | free(ptr); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 618 | } |
| 619 | |
Alyssa Rosenzweig | 6ec33b4 | 2019-08-21 11:46:06 -0700 | [diff] [blame] | 620 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | static void |
Alyssa Rosenzweig | ae84f16 | 2019-08-22 11:30:13 -0700 | [diff] [blame] | 624 | pandecode_uniforms(mali_ptr uniforms, unsigned uniform_count) |
| 625 | { |
| 626 | pandecode_validate_buffer(uniforms, uniform_count * 16); |
| 627 | |
| 628 | char *ptr = pointer_as_memory_reference(uniforms); |
| 629 | pandecode_log("vec4 uniforms[%u] = %s;\n", uniform_count, ptr); |
| 630 | free(ptr); |
Boris Brezillon | b1c3f63 | 2020-09-10 12:46:33 +0200 | [diff] [blame] | 631 | pandecode_log("\n"); |
Alyssa Rosenzweig | ae84f16 | 2019-08-22 11:30:13 -0700 | [diff] [blame] | 632 | } |
| 633 | |
Alyssa Rosenzweig | 09671c8 | 2019-12-23 11:40:40 -0500 | [diff] [blame] | 634 | static const char * |
| 635 | shader_type_for_job(unsigned type) |
| 636 | { |
| 637 | switch (type) { |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 638 | case MALI_JOB_TYPE_VERTEX: return "VERTEX"; |
| 639 | case MALI_JOB_TYPE_TILER: return "FRAGMENT"; |
| 640 | case MALI_JOB_TYPE_COMPUTE: return "COMPUTE"; |
Alyssa Rosenzweig | 8004906 | 2020-08-26 16:52:53 -0400 | [diff] [blame] | 641 | default: return "UNKNOWN"; |
Alyssa Rosenzweig | 09671c8 | 2019-12-23 11:40:40 -0500 | [diff] [blame] | 642 | } |
| 643 | } |
| 644 | |
Alyssa Rosenzweig | c4a4f3d | 2019-08-14 09:19:54 -0700 | [diff] [blame] | 645 | static unsigned shader_id = 0; |
| 646 | |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 647 | static struct midgard_disasm_stats |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 648 | pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type, |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 649 | bool is_bifrost, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 650 | { |
| 651 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(shader_ptr); |
| 652 | uint8_t *PANDECODE_PTR_VAR(code, mem, shader_ptr); |
| 653 | |
| 654 | /* Compute maximum possible size */ |
| 655 | size_t sz = mem->length - (shader_ptr - mem->gpu_va); |
| 656 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 657 | /* Print some boilerplate to clearly denote the assembly (which doesn't |
| 658 | * obey indentation rules), and actually do the disassembly! */ |
| 659 | |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 660 | pandecode_log_cont("\n\n"); |
Alyssa Rosenzweig | 50382df | 2019-05-18 18:58:56 +0000 | [diff] [blame] | 661 | |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 662 | struct midgard_disasm_stats stats; |
Alyssa Rosenzweig | c4a4f3d | 2019-08-14 09:19:54 -0700 | [diff] [blame] | 663 | |
Alyssa Rosenzweig | 50382df | 2019-05-18 18:58:56 +0000 | [diff] [blame] | 664 | if (is_bifrost) { |
Alyssa Rosenzweig | c88f816 | 2020-03-27 22:34:15 -0400 | [diff] [blame] | 665 | disassemble_bifrost(pandecode_dump_stream, code, sz, true); |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 666 | |
| 667 | /* TODO: Extend stats to Bifrost */ |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 668 | stats.texture_count = -128; |
| 669 | stats.sampler_count = -128; |
| 670 | stats.attribute_count = -128; |
| 671 | stats.varying_count = -128; |
| 672 | stats.uniform_count = -128; |
| 673 | stats.uniform_buffer_count = -128; |
| 674 | stats.work_count = -128; |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 675 | |
| 676 | stats.instruction_count = 0; |
| 677 | stats.bundle_count = 0; |
| 678 | stats.quadword_count = 0; |
Alyssa Rosenzweig | d6d6d63 | 2019-08-30 17:00:09 -0700 | [diff] [blame] | 679 | stats.helper_invocations = false; |
Alyssa Rosenzweig | 50382df | 2019-05-18 18:58:56 +0000 | [diff] [blame] | 680 | } else { |
Icecream95 | be22c07 | 2020-01-23 10:14:35 +1300 | [diff] [blame] | 681 | stats = disassemble_midgard(pandecode_dump_stream, |
| 682 | code, sz, gpu_id, |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 683 | type == MALI_JOB_TYPE_TILER ? |
Alyssa Rosenzweig | ac14fac | 2019-11-07 09:31:02 -0500 | [diff] [blame] | 684 | MESA_SHADER_FRAGMENT : MESA_SHADER_VERTEX); |
Alyssa Rosenzweig | 50382df | 2019-05-18 18:58:56 +0000 | [diff] [blame] | 685 | } |
| 686 | |
Alyssa Rosenzweig | c088a3b | 2020-08-26 16:52:23 -0400 | [diff] [blame] | 687 | unsigned nr_threads = |
| 688 | (stats.work_count <= 4) ? 4 : |
| 689 | (stats.work_count <= 8) ? 2 : |
| 690 | 1; |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 691 | |
Alyssa Rosenzweig | c088a3b | 2020-08-26 16:52:23 -0400 | [diff] [blame] | 692 | pandecode_log_cont("shader%d - MESA_SHADER_%s shader: " |
| 693 | "%u inst, %u bundles, %u quadwords, " |
| 694 | "%u registers, %u threads, 0 loops, 0:0 spills:fills\n\n\n", |
| 695 | shader_id++, |
| 696 | shader_type_for_job(type), |
| 697 | stats.instruction_count, stats.bundle_count, stats.quadword_count, |
| 698 | stats.work_count, nr_threads); |
Alyssa Rosenzweig | 58fc260 | 2019-08-21 14:00:46 -0700 | [diff] [blame] | 699 | |
| 700 | return stats; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | static void |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 704 | pandecode_texture_payload(mali_ptr payload, |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 705 | enum mali_texture_dimension dim, |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 706 | enum mali_texture_layout layout, |
| 707 | bool manual_stride, |
| 708 | uint8_t levels, |
| 709 | uint16_t depth, |
| 710 | uint16_t array_size, |
| 711 | struct pandecode_mapped_memory *tmem) |
| 712 | { |
| 713 | pandecode_log(".payload = {\n"); |
| 714 | pandecode_indent++; |
| 715 | |
| 716 | /* A bunch of bitmap pointers follow. |
| 717 | * We work out the correct number, |
| 718 | * based on the mipmap/cubemap |
| 719 | * properties, but dump extra |
| 720 | * possibilities to futureproof */ |
| 721 | |
| 722 | int bitmap_count = levels + 1; |
| 723 | |
| 724 | /* Miptree for each face */ |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 725 | if (dim == MALI_TEXTURE_DIMENSION_CUBE) |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 726 | bitmap_count *= 6; |
Alyssa Rosenzweig | eba9bcd | 2020-06-30 16:21:30 -0400 | [diff] [blame] | 727 | |
| 728 | /* Array of layers */ |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 729 | bitmap_count *= depth; |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 730 | |
| 731 | /* Array of textures */ |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 732 | bitmap_count *= array_size; |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 733 | |
| 734 | /* Stride for each element */ |
| 735 | if (manual_stride) |
| 736 | bitmap_count *= 2; |
| 737 | |
| 738 | mali_ptr *pointers_and_strides = pandecode_fetch_gpu_mem(tmem, |
| 739 | payload, sizeof(mali_ptr) * bitmap_count); |
| 740 | for (int i = 0; i < bitmap_count; ++i) { |
| 741 | /* How we dump depends if this is a stride or a pointer */ |
| 742 | |
| 743 | if (manual_stride && (i & 1)) { |
| 744 | /* signed 32-bit snuck in as a 64-bit pointer */ |
| 745 | uint64_t stride_set = pointers_and_strides[i]; |
| 746 | uint32_t clamped_stride = stride_set; |
| 747 | int32_t stride = clamped_stride; |
| 748 | assert(stride_set == clamped_stride); |
| 749 | pandecode_log("(mali_ptr) %d /* stride */, \n", stride); |
| 750 | } else { |
| 751 | char *a = pointer_as_memory_reference(pointers_and_strides[i]); |
| 752 | pandecode_log("%s, \n", a); |
| 753 | free(a); |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | pandecode_indent--; |
| 758 | pandecode_log("},\n"); |
| 759 | } |
| 760 | |
| 761 | static void |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 762 | pandecode_texture(mali_ptr u, |
| 763 | struct pandecode_mapped_memory *tmem, |
| 764 | unsigned job_no, unsigned tex) |
| 765 | { |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 766 | struct pandecode_mapped_memory *mapped_mem = pandecode_find_mapped_gpu_mem_containing(u); |
| 767 | 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] | 768 | |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 769 | pan_unpack(cl, MIDGARD_TEXTURE, temp); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 770 | DUMP_UNPACKED(MIDGARD_TEXTURE, temp, "Texture:\n") |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 771 | |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 772 | pandecode_indent++; |
Alyssa Rosenzweig | f008a63 | 2020-08-11 17:27:36 -0400 | [diff] [blame] | 773 | pandecode_texture_payload(u + MALI_MIDGARD_TEXTURE_LENGTH, |
| 774 | temp.dimension, temp.texel_ordering, temp.manual_stride, |
| 775 | temp.levels, temp.depth, temp.array_size, mapped_mem); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 776 | pandecode_indent--; |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 777 | } |
| 778 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 779 | static void |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 780 | pandecode_bifrost_texture( |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 781 | const void *cl, |
Alyssa Rosenzweig | a3d2936 | 2020-04-21 16:08:07 -0400 | [diff] [blame] | 782 | unsigned job_no, |
| 783 | unsigned tex) |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 784 | { |
Boris Brezillon | 706974c | 2020-09-15 09:25:18 +0200 | [diff] [blame] | 785 | pan_unpack(cl, BIFROST_TEXTURE, temp); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 786 | DUMP_UNPACKED(BIFROST_TEXTURE, temp, "Texture:\n") |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 787 | |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 788 | 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] | 789 | pandecode_indent++; |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 790 | pandecode_texture_payload(temp.surfaces, temp.dimension, temp.texel_ordering, |
| 791 | true, temp.levels, 1, 1, tmem); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 792 | pandecode_indent--; |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 793 | } |
| 794 | |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 795 | /* 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 */ |
| 796 | |
| 797 | static void |
| 798 | pandecode_shader_prop(const char *name, unsigned claim, signed truth, bool fuzzy) |
| 799 | { |
| 800 | /* Nothing to do */ |
| 801 | if (claim == truth) |
| 802 | return; |
| 803 | |
Alyssa Rosenzweig | 5815f33 | 2020-02-25 17:29:55 -0500 | [diff] [blame] | 804 | if (fuzzy && (truth < 0)) |
| 805 | 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] | 806 | |
| 807 | if ((truth >= 0) && !fuzzy) { |
Alyssa Rosenzweig | f48136e | 2019-08-22 09:02:48 -0700 | [diff] [blame] | 808 | pandecode_msg("%s: expected %s = %d, claimed %u\n", |
| 809 | (truth < claim) ? "warn" : "XXX", |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 810 | name, truth, claim); |
| 811 | } else if ((claim > -truth) && !fuzzy) { |
| 812 | pandecode_msg("XXX: expected %s <= %u, claimed %u\n", |
| 813 | name, -truth, claim); |
| 814 | } else if (fuzzy && (claim < truth)) |
| 815 | pandecode_msg("XXX: expected %s >= %u, claimed %u\n", |
| 816 | name, truth, claim); |
| 817 | |
| 818 | pandecode_log(".%s = %" PRId16, name, claim); |
| 819 | |
| 820 | if (fuzzy) |
| 821 | pandecode_log_cont(" /* %u used */", truth); |
| 822 | |
| 823 | pandecode_log_cont(",\n"); |
| 824 | } |
| 825 | |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 826 | static void |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 827 | 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] | 828 | bool is_bifrost, unsigned gpu_id) |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 829 | { |
| 830 | struct midgard_disasm_stats stats = |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 831 | pandecode_shader_disassemble(shader, job_no, job_type, is_bifrost, gpu_id); |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 832 | |
| 833 | bool has_texture = (stats.texture_count > 0); |
| 834 | bool has_sampler = (stats.sampler_count > 0); |
| 835 | bool has_attribute = (stats.attribute_count > 0); |
| 836 | bool has_varying = (stats.varying_count > 0); |
| 837 | bool has_uniform = (stats.uniform_count > 0); |
| 838 | bool has_ubo = (stats.uniform_buffer_count > 0); |
| 839 | |
| 840 | if (has_texture || has_sampler) |
| 841 | pandecode_msg("XXX: blend shader accessing textures\n"); |
| 842 | |
| 843 | if (has_attribute || has_varying) |
| 844 | pandecode_msg("XXX: blend shader accessing interstage\n"); |
| 845 | |
| 846 | if (has_uniform || has_ubo) |
| 847 | pandecode_msg("XXX: blend shader accessing uniforms\n"); |
| 848 | } |
| 849 | |
| 850 | static void |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 851 | pandecode_textures(mali_ptr textures, unsigned texture_count, int job_no, bool is_bifrost) |
| 852 | { |
| 853 | struct pandecode_mapped_memory *mmem = pandecode_find_mapped_gpu_mem_containing(textures); |
| 854 | |
| 855 | if (!mmem) |
| 856 | return; |
| 857 | |
Boris Brezillon | b1c3f63 | 2020-09-10 12:46:33 +0200 | [diff] [blame] | 858 | pandecode_log("Textures %"PRIx64"_%d:\n", textures, job_no); |
| 859 | pandecode_indent++; |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 860 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 861 | if (is_bifrost) { |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 862 | const void *cl = pandecode_fetch_gpu_mem(mmem, |
| 863 | textures, MALI_BIFROST_TEXTURE_LENGTH * |
| 864 | texture_count); |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 865 | |
Alyssa Rosenzweig | ad0b32c | 2020-08-06 18:12:28 -0400 | [diff] [blame] | 866 | for (unsigned tex = 0; tex < texture_count; ++tex) { |
| 867 | pandecode_bifrost_texture(cl + |
| 868 | MALI_BIFROST_TEXTURE_LENGTH * tex, |
| 869 | job_no, tex); |
| 870 | } |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 871 | } else { |
| 872 | mali_ptr *PANDECODE_PTR_VAR(u, mmem, textures); |
| 873 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 874 | for (int tex = 0; tex < texture_count; ++tex) { |
| 875 | mali_ptr *PANDECODE_PTR_VAR(u, mmem, textures + tex * sizeof(mali_ptr)); |
| 876 | char *a = pointer_as_memory_reference(*u); |
| 877 | pandecode_log("%s,\n", a); |
| 878 | free(a); |
| 879 | } |
| 880 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 881 | /* Now, finally, descend down into the texture descriptor */ |
| 882 | for (unsigned tex = 0; tex < texture_count; ++tex) { |
| 883 | mali_ptr *PANDECODE_PTR_VAR(u, mmem, textures + tex * sizeof(mali_ptr)); |
| 884 | struct pandecode_mapped_memory *tmem = pandecode_find_mapped_gpu_mem_containing(*u); |
| 885 | if (tmem) |
| 886 | pandecode_texture(*u, tmem, job_no, tex); |
| 887 | } |
| 888 | } |
Boris Brezillon | b1c3f63 | 2020-09-10 12:46:33 +0200 | [diff] [blame] | 889 | pandecode_indent--; |
| 890 | pandecode_log("\n"); |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 891 | } |
| 892 | |
| 893 | static void |
| 894 | pandecode_samplers(mali_ptr samplers, unsigned sampler_count, int job_no, bool is_bifrost) |
| 895 | { |
Boris Brezillon | b1c3f63 | 2020-09-10 12:46:33 +0200 | [diff] [blame] | 896 | pandecode_log("Samplers %"PRIx64"_%d:\n", samplers, job_no); |
| 897 | pandecode_indent++; |
| 898 | |
Alyssa Rosenzweig | b10c3c8 | 2020-08-11 18:25:03 -0400 | [diff] [blame] | 899 | for (int i = 0; i < sampler_count; ++i) { |
| 900 | if (is_bifrost) { |
Boris Brezillon | b1c3f63 | 2020-09-10 12:46:33 +0200 | [diff] [blame] | 901 | DUMP_ADDR(BIFROST_SAMPLER, samplers + (MALI_BIFROST_SAMPLER_LENGTH * i), "Sampler %d:\n", i); |
Alyssa Rosenzweig | b10c3c8 | 2020-08-11 18:25:03 -0400 | [diff] [blame] | 902 | } else { |
Boris Brezillon | b1c3f63 | 2020-09-10 12:46:33 +0200 | [diff] [blame] | 903 | DUMP_ADDR(MIDGARD_SAMPLER, samplers + (MALI_MIDGARD_SAMPLER_LENGTH * i), "Sampler %d:\n", i); |
Alyssa Rosenzweig | b10c3c8 | 2020-08-11 18:25:03 -0400 | [diff] [blame] | 904 | } |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 905 | } |
Boris Brezillon | b1c3f63 | 2020-09-10 12:46:33 +0200 | [diff] [blame] | 906 | |
| 907 | pandecode_indent--; |
| 908 | pandecode_log("\n"); |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | static void |
Alyssa Rosenzweig | 8fc4ca8 | 2019-08-20 14:48:55 -0700 | [diff] [blame] | 912 | pandecode_vertex_tiler_postfix_pre( |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 913 | const struct MALI_DRAW *p, |
Alyssa Rosenzweig | 7318b52 | 2019-07-10 10:36:16 -0700 | [diff] [blame] | 914 | int job_no, enum mali_job_type job_type, |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 915 | char *suffix, bool is_bifrost, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 916 | { |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 917 | struct pandecode_mapped_memory *attr_mem; |
| 918 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 919 | struct pandecode_fbd fbd_info = { |
| 920 | /* Default for Bifrost */ |
| 921 | .rt_count = 1 |
| 922 | }; |
| 923 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 924 | if (is_bifrost) |
Boris Brezillon | d343f23 | 2020-09-29 10:45:23 +0200 | [diff] [blame] | 925 | pandecode_compute_fbd(p->fbd & ~1, job_no); |
| 926 | else if (p->fbd & MALI_FBD_TAG_IS_MFBD) |
| 927 | fbd_info = pandecode_mfbd_bfr((u64) ((uintptr_t) p->fbd) & ~MALI_FBD_TAG_MASK, |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 928 | job_no, false, job_type == MALI_JOB_TYPE_COMPUTE, is_bifrost, gpu_id); |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 929 | else if (job_type == MALI_JOB_TYPE_COMPUTE) |
Boris Brezillon | d343f23 | 2020-09-29 10:45:23 +0200 | [diff] [blame] | 930 | pandecode_compute_fbd((u64) (uintptr_t) p->fbd, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 931 | else |
Boris Brezillon | d343f23 | 2020-09-29 10:45:23 +0200 | [diff] [blame] | 932 | fbd_info = pandecode_sfbd((u64) (uintptr_t) p->fbd, job_no, false, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 933 | |
| 934 | int varying_count = 0, attribute_count = 0, uniform_count = 0, uniform_buffer_count = 0; |
| 935 | int texture_count = 0, sampler_count = 0; |
| 936 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 937 | if (p->state) { |
| 938 | struct pandecode_mapped_memory *smem = pandecode_find_mapped_gpu_mem_containing(p->state); |
Boris Brezillon | f734e67 | 2020-09-29 15:47:04 +0200 | [diff] [blame] | 939 | uint32_t *cl = pandecode_fetch_gpu_mem(smem, p->state, MALI_RENDERER_STATE_LENGTH); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 940 | |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 941 | /* Disassemble ahead-of-time to get stats. Initialize with |
| 942 | * stats for the missing-shader case so we get validation |
| 943 | * there, too */ |
| 944 | |
| 945 | struct midgard_disasm_stats info = { |
| 946 | .texture_count = 0, |
| 947 | .sampler_count = 0, |
| 948 | .attribute_count = 0, |
| 949 | .varying_count = 0, |
| 950 | .work_count = 1, |
| 951 | |
| 952 | .uniform_count = -128, |
| 953 | .uniform_buffer_count = 0 |
| 954 | }; |
Alyssa Rosenzweig | 9b067d9 | 2019-08-21 14:28:36 -0700 | [diff] [blame] | 955 | |
Boris Brezillon | f734e67 | 2020-09-29 15:47:04 +0200 | [diff] [blame] | 956 | pan_unpack(cl, RENDERER_STATE, state); |
Alyssa Rosenzweig | 661b469 | 2020-08-21 10:34:06 -0400 | [diff] [blame] | 957 | |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 958 | if (state.shader.shader & ~0xF) |
| 959 | 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] | 960 | |
Boris Brezillon | f734e67 | 2020-09-29 15:47:04 +0200 | [diff] [blame] | 961 | DUMP_UNPACKED(RENDERER_STATE, state, "State:\n"); |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 962 | pandecode_indent++; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 963 | |
| 964 | /* Save for dumps */ |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 965 | attribute_count = state.shader.attribute_count; |
| 966 | varying_count = state.shader.varying_count; |
| 967 | texture_count = state.shader.texture_count; |
| 968 | sampler_count = state.shader.sampler_count; |
Boris Brezillon | 7bb85ea | 2020-09-15 17:03:28 +0200 | [diff] [blame] | 969 | uniform_buffer_count = state.properties.uniform_buffer_count; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 970 | |
Boris Brezillon | 7bb85ea | 2020-09-15 17:03:28 +0200 | [diff] [blame] | 971 | if (is_bifrost) |
Alyssa Rosenzweig | 3d7ce13 | 2020-08-21 19:59:22 -0400 | [diff] [blame] | 972 | uniform_count = state.preload.uniform_count; |
Boris Brezillon | 7bb85ea | 2020-09-15 17:03:28 +0200 | [diff] [blame] | 973 | else |
Boris Brezillon | 519643b | 2020-10-13 18:32:14 +0200 | [diff] [blame^] | 974 | uniform_count = state.properties.midgard.uniform_count; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 975 | |
Alyssa Rosenzweig | 661b469 | 2020-08-21 10:34:06 -0400 | [diff] [blame] | 976 | pandecode_shader_prop("texture_count", texture_count, info.texture_count, false); |
| 977 | pandecode_shader_prop("sampler_count", sampler_count, info.sampler_count, false); |
| 978 | pandecode_shader_prop("attribute_count", attribute_count, info.attribute_count, false); |
| 979 | pandecode_shader_prop("varying_count", varying_count, info.varying_count, false); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 980 | |
Boris Brezillon | 7bb85ea | 2020-09-15 17:03:28 +0200 | [diff] [blame] | 981 | if (is_bifrost) |
| 982 | DUMP_UNPACKED(PRELOAD, state.preload, "Preload:\n"); |
Alyssa Rosenzweig | 7a95ed2 | 2020-08-20 20:42:32 -0400 | [diff] [blame] | 983 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 984 | if (!is_bifrost) { |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 985 | /* TODO: Blend shaders routing/disasm */ |
Boris Brezillon | 713419e | 2020-09-16 10:26:06 +0200 | [diff] [blame] | 986 | pandecode_log("SFBD Blend:\n"); |
| 987 | pandecode_indent++; |
Boris Brezillon | 7bb85ea | 2020-09-15 17:03:28 +0200 | [diff] [blame] | 988 | if (state.multisample_misc.sfbd_blend_shader) { |
Boris Brezillon | 713419e | 2020-09-16 10:26:06 +0200 | [diff] [blame] | 989 | pandecode_shader_address("Shader", state.sfbd_blend_shader); |
Boris Brezillon | 7bb85ea | 2020-09-15 17:03:28 +0200 | [diff] [blame] | 990 | } else { |
Boris Brezillon | 713419e | 2020-09-16 10:26:06 +0200 | [diff] [blame] | 991 | DUMP_UNPACKED(BLEND_EQUATION, state.sfbd_blend_equation, "Equation:\n"); |
| 992 | pandecode_prop("Constant = %f", state.sfbd_blend_constant); |
Boris Brezillon | 7bb85ea | 2020-09-15 17:03:28 +0200 | [diff] [blame] | 993 | } |
Boris Brezillon | 713419e | 2020-09-16 10:26:06 +0200 | [diff] [blame] | 994 | pandecode_indent--; |
| 995 | pandecode_log("\n"); |
| 996 | |
| 997 | mali_ptr shader = state.sfbd_blend_shader & ~0xF; |
| 998 | if (state.multisample_misc.sfbd_blend_shader && shader) |
Tomeu Vizoso | 072207b | 2019-11-07 08:27:53 +0100 | [diff] [blame] | 999 | pandecode_blend_shader_disassemble(shader, job_no, job_type, false, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1000 | } |
Boris Brezillon | aa2670c | 2020-09-05 18:14:17 +0200 | [diff] [blame] | 1001 | pandecode_indent--; |
Boris Brezillon | b1c3f63 | 2020-09-10 12:46:33 +0200 | [diff] [blame] | 1002 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1003 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1004 | /* MRT blend fields are used whenever MFBD is used, with |
| 1005 | * per-RT descriptors */ |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1006 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1007 | if (job_type == MALI_JOB_TYPE_TILER && |
Boris Brezillon | d343f23 | 2020-09-29 10:45:23 +0200 | [diff] [blame] | 1008 | (is_bifrost || p->fbd & MALI_FBD_TAG_IS_MFBD)) { |
Boris Brezillon | f734e67 | 2020-09-29 15:47:04 +0200 | [diff] [blame] | 1009 | void* blend_base = ((void *) cl) + MALI_RENDERER_STATE_LENGTH; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1010 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1011 | for (unsigned i = 0; i < fbd_info.rt_count; i++) { |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1012 | mali_ptr shader = 0; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1013 | |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1014 | if (is_bifrost) |
Boris Brezillon | 8389976 | 2020-09-16 13:31:37 +0200 | [diff] [blame] | 1015 | shader = pandecode_bifrost_blend(blend_base, job_no, i, |
| 1016 | state.shader.shader); |
| 1017 | else |
Alyssa Rosenzweig | 050b934 | 2019-05-04 21:57:01 +0000 | [diff] [blame] | 1018 | shader = pandecode_midgard_blend_mrt(blend_base, job_no, i); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1019 | |
Tomeu Vizoso | 8e1ae5f | 2019-11-05 15:31:42 +0100 | [diff] [blame] | 1020 | if (shader & ~0xF) |
Boris Brezillon | 8389976 | 2020-09-16 13:31:37 +0200 | [diff] [blame] | 1021 | pandecode_blend_shader_disassemble(shader, job_no, job_type, |
| 1022 | is_bifrost, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1023 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1024 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1025 | } else |
Alyssa Rosenzweig | 5f9a1c7 | 2019-08-21 14:16:32 -0700 | [diff] [blame] | 1026 | pandecode_msg("XXX: missing shader descriptor\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1027 | |
Boris Brezillon | b1c3f63 | 2020-09-10 12:46:33 +0200 | [diff] [blame] | 1028 | if (p->viewport) { |
Boris Brezillon | 670e818 | 2020-09-09 17:56:53 +0200 | [diff] [blame] | 1029 | DUMP_ADDR(VIEWPORT, p->viewport, "Viewport:\n"); |
Boris Brezillon | b1c3f63 | 2020-09-10 12:46:33 +0200 | [diff] [blame] | 1030 | pandecode_log("\n"); |
| 1031 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1032 | |
Alyssa Rosenzweig | ed464e0 | 2019-08-22 13:07:01 -0700 | [diff] [blame] | 1033 | unsigned max_attr_index = 0; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1034 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1035 | if (p->attributes) |
| 1036 | max_attr_index = pandecode_attribute_meta(attribute_count, p->attributes, false, suffix); |
Alyssa Rosenzweig | ed464e0 | 2019-08-22 13:07:01 -0700 | [diff] [blame] | 1037 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1038 | if (p->attribute_buffers) { |
| 1039 | attr_mem = pandecode_find_mapped_gpu_mem_containing(p->attribute_buffers); |
| 1040 | 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] | 1041 | } |
| 1042 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1043 | if (p->varyings) { |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1044 | varying_count = pandecode_attribute_meta(varying_count, p->varyings, true, suffix); |
| 1045 | } |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1046 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1047 | if (p->varying_buffers) { |
| 1048 | attr_mem = pandecode_find_mapped_gpu_mem_containing(p->varying_buffers); |
| 1049 | 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] | 1050 | } |
| 1051 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1052 | if (p->uniform_buffers) { |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1053 | if (uniform_buffer_count) |
| 1054 | pandecode_uniform_buffers(p->uniform_buffers, uniform_buffer_count, job_no); |
| 1055 | else |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1056 | pandecode_msg("warn: UBOs specified but not referenced\n"); |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1057 | } else if (uniform_buffer_count) |
| 1058 | pandecode_msg("XXX: UBOs referenced but not specified\n"); |
| 1059 | |
| 1060 | /* We don't want to actually dump uniforms, but we do need to validate |
| 1061 | * that the counts we were given are sane */ |
| 1062 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1063 | if (p->push_uniforms) { |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1064 | if (uniform_count) |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1065 | pandecode_uniforms(p->push_uniforms, uniform_count); |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1066 | else |
Alyssa Rosenzweig | cbbf754 | 2019-08-21 14:57:23 -0700 | [diff] [blame] | 1067 | pandecode_msg("warn: Uniforms specified but not referenced\n"); |
Alyssa Rosenzweig | 4aeb694 | 2019-08-19 15:16:01 -0700 | [diff] [blame] | 1068 | } else if (uniform_count) |
Alyssa Rosenzweig | d7473e2 | 2019-08-21 14:15:05 -0700 | [diff] [blame] | 1069 | pandecode_msg("XXX: Uniforms referenced but not specified\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1070 | |
Alyssa Rosenzweig | 497977b | 2020-03-09 13:51:39 -0400 | [diff] [blame] | 1071 | if (p->textures) |
| 1072 | pandecode_textures(p->textures, texture_count, job_no, is_bifrost); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1073 | |
Alyssa Rosenzweig | 7602891 | 2020-08-26 17:05:41 -0400 | [diff] [blame] | 1074 | if (p->samplers) |
| 1075 | pandecode_samplers(p->samplers, sampler_count, job_no, is_bifrost); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1076 | } |
| 1077 | |
| 1078 | static void |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1079 | pandecode_bifrost_tiler_heap(mali_ptr gpu_va, int job_no) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1080 | { |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1081 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1082 | pan_unpack(PANDECODE_PTR(mem, gpu_va, void), BIFROST_TILER_HEAP, h); |
| 1083 | DUMP_UNPACKED(BIFROST_TILER_HEAP, h, "Bifrost Tiler Heap:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1084 | } |
| 1085 | |
| 1086 | static void |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1087 | pandecode_bifrost_tiler(mali_ptr gpu_va, int job_no) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1088 | { |
| 1089 | struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1090 | pan_unpack(PANDECODE_PTR(mem, gpu_va, void), BIFROST_TILER, t); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1091 | |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1092 | pandecode_bifrost_tiler_heap(t.heap, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1093 | |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1094 | DUMP_UNPACKED(BIFROST_TILER, t, "Bifrost Tiler:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1095 | pandecode_indent++; |
Boris Brezillon | efce73d | 2020-09-08 10:11:26 +0200 | [diff] [blame] | 1096 | if (t.hierarchy_mask != 0xa && |
| 1097 | t.hierarchy_mask != 0x14 && |
| 1098 | t.hierarchy_mask != 0x28 && |
| 1099 | t.hierarchy_mask != 0x50 && |
| 1100 | t.hierarchy_mask != 0xa0) |
Tomeu Vizoso | 0a0b670 | 2020-04-09 09:39:17 +0200 | [diff] [blame] | 1101 | pandecode_prop("XXX: Unexpected hierarchy_mask (not 0xa, 0x14, 0x28, 0x50 or 0xa0)!"); |
| 1102 | |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1103 | pandecode_indent--; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1104 | } |
| 1105 | |
| 1106 | static void |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1107 | pandecode_primitive_size(const void *s, bool constant) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1108 | { |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1109 | pan_unpack(s, PRIMITIVE_SIZE, ps); |
| 1110 | if (ps.size_array == 0x0) |
Alyssa Rosenzweig | 2608da1 | 2019-06-19 09:35:57 -0700 | [diff] [blame] | 1111 | return; |
| 1112 | |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1113 | DUMP_UNPACKED(PRIMITIVE_SIZE, ps, "Primitive Size:\n") |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1114 | } |
| 1115 | |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1116 | static void |
| 1117 | pandecode_vertex_compute_geometry_job(const struct MALI_JOB_HEADER *h, |
| 1118 | const struct pandecode_mapped_memory *mem, |
| 1119 | mali_ptr job, int job_no, bool is_bifrost, |
| 1120 | unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1121 | { |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1122 | struct mali_compute_job_packed *PANDECODE_PTR_VAR(p, mem, job); |
| 1123 | pan_section_unpack(p, COMPUTE_JOB, DRAW, draw); |
| 1124 | pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", is_bifrost, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1125 | |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1126 | pandecode_log("Vertex Job Payload:\n"); |
| 1127 | pandecode_indent++; |
| 1128 | pandecode_invocation(pan_section_ptr(p, COMPUTE_JOB, INVOCATION), |
| 1129 | h->type != MALI_JOB_TYPE_COMPUTE); |
| 1130 | DUMP_SECTION(COMPUTE_JOB, PARAMETERS, p, "Vertex Job Parameters:\n"); |
| 1131 | DUMP_UNPACKED(DRAW, draw, "Draw:\n"); |
| 1132 | pandecode_indent--; |
| 1133 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1134 | } |
| 1135 | |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1136 | static void |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame] | 1137 | pandecode_tiler_job_bfr(const struct MALI_JOB_HEADER *h, |
| 1138 | const struct pandecode_mapped_memory *mem, |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1139 | mali_ptr job, int job_no, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1140 | { |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1141 | struct mali_bifrost_tiler_job_packed *PANDECODE_PTR_VAR(p, mem, job); |
| 1142 | pan_section_unpack(p, BIFROST_TILER_JOB, DRAW, draw); |
| 1143 | pan_section_unpack(p, BIFROST_TILER_JOB, TILER, tiler_ptr); |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame] | 1144 | pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", true, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1145 | |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1146 | pandecode_log("Tiler Job Payload:\n"); |
| 1147 | pandecode_indent++; |
| 1148 | pandecode_bifrost_tiler(tiler_ptr.address, job_no); |
| 1149 | |
| 1150 | pandecode_invocation(pan_section_ptr(p, BIFROST_TILER_JOB, INVOCATION), true); |
| 1151 | pandecode_primitive(pan_section_ptr(p, BIFROST_TILER_JOB, PRIMITIVE)); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1152 | |
Alyssa Rosenzweig | 4467e79 | 2020-08-26 13:21:06 -0400 | [diff] [blame] | 1153 | /* TODO: gl_PointSize on Bifrost */ |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1154 | pandecode_primitive_size(pan_section_ptr(p, BIFROST_TILER_JOB, PRIMITIVE_SIZE), true); |
| 1155 | pan_section_unpack(p, BIFROST_TILER_JOB, PADDING, padding); |
| 1156 | DUMP_UNPACKED(DRAW, draw, "Draw:\n"); |
| 1157 | pandecode_indent--; |
| 1158 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1159 | } |
| 1160 | |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1161 | static void |
| 1162 | pandecode_tiler_job_mdg(const struct MALI_JOB_HEADER *h, |
| 1163 | const struct pandecode_mapped_memory *mem, |
| 1164 | mali_ptr job, int job_no, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1165 | { |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1166 | struct mali_midgard_tiler_job_packed *PANDECODE_PTR_VAR(p, mem, job); |
| 1167 | pan_section_unpack(p, MIDGARD_TILER_JOB, DRAW, draw); |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame] | 1168 | pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->type, "", false, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1169 | |
Vinson Lee | d9c4ec9 | 2020-09-22 17:22:12 -0700 | [diff] [blame] | 1170 | pandecode_log("Tiler Job Payload:\n"); |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1171 | pandecode_indent++; |
| 1172 | pandecode_invocation(pan_section_ptr(p, MIDGARD_TILER_JOB, INVOCATION), true); |
| 1173 | pandecode_primitive(pan_section_ptr(p, MIDGARD_TILER_JOB, PRIMITIVE)); |
| 1174 | DUMP_UNPACKED(DRAW, draw, "Draw:\n"); |
Alyssa Rosenzweig | b010a6d | 2020-04-06 20:31:32 -0400 | [diff] [blame] | 1175 | |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1176 | pan_section_unpack(p, MIDGARD_TILER_JOB, PRIMITIVE, primitive); |
| 1177 | pandecode_primitive_size(pan_section_ptr(p, MIDGARD_TILER_JOB, PRIMITIVE_SIZE), |
Boris Brezillon | 51331d6 | 2020-09-29 11:21:33 +0200 | [diff] [blame] | 1178 | primitive.point_size_array_format == MALI_POINT_SIZE_ARRAY_FORMAT_NONE); |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1179 | pandecode_indent--; |
| 1180 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1181 | } |
| 1182 | |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1183 | static void |
Alyssa Rosenzweig | 7103baf | 2019-07-12 08:57:10 -0700 | [diff] [blame] | 1184 | pandecode_fragment_job(const struct pandecode_mapped_memory *mem, |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1185 | mali_ptr job, int job_no, |
| 1186 | bool is_bifrost, unsigned gpu_id) |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1187 | { |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1188 | struct mali_fragment_job_packed *PANDECODE_PTR_VAR(p, mem, job); |
| 1189 | pan_section_unpack(p, FRAGMENT_JOB, PAYLOAD, s); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1190 | |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1191 | bool is_mfbd = s.framebuffer & MALI_FBD_TAG_IS_MFBD; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1192 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1193 | if (!is_mfbd && is_bifrost) |
| 1194 | pandecode_msg("XXX: Bifrost fragment must use MFBD\n"); |
| 1195 | |
| 1196 | struct pandecode_fbd info; |
| 1197 | |
| 1198 | if (is_mfbd) |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1199 | info = pandecode_mfbd_bfr(s.framebuffer & ~MALI_FBD_TAG_MASK, job_no, |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1200 | true, false, is_bifrost, gpu_id); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1201 | else |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1202 | info = pandecode_sfbd(s.framebuffer & ~MALI_FBD_TAG_MASK, job_no, |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1203 | true, gpu_id); |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1204 | |
| 1205 | /* Compute the tag for the tagged pointer. This contains the type of |
| 1206 | * FBD (MFBD/SFBD), and in the case of an MFBD, information about which |
| 1207 | * additional structures follow the MFBD header (an extra payload or |
| 1208 | * not, as well as a count of render targets) */ |
| 1209 | |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1210 | unsigned expected_tag = is_mfbd ? MALI_FBD_TAG_IS_MFBD : 0; |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1211 | |
| 1212 | if (is_mfbd) { |
| 1213 | if (info.has_extra) |
Boris Brezillon | 5d5f755 | 2020-09-08 10:17:40 +0200 | [diff] [blame] | 1214 | expected_tag |= MALI_FBD_TAG_HAS_ZS_RT; |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1215 | |
| 1216 | expected_tag |= (MALI_POSITIVE(info.rt_count) << 2); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1217 | } |
| 1218 | |
Alyssa Rosenzweig | ded9a68 | 2019-08-21 12:29:47 -0700 | [diff] [blame] | 1219 | /* Extract tile coordinates */ |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1220 | |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1221 | unsigned min_x = s.bound_min_x << MALI_TILE_SHIFT; |
| 1222 | unsigned min_y = s.bound_min_y << MALI_TILE_SHIFT; |
| 1223 | unsigned max_x = s.bound_max_x << MALI_TILE_SHIFT; |
| 1224 | unsigned max_y = s.bound_max_y << MALI_TILE_SHIFT; |
Alyssa Rosenzweig | ded9a68 | 2019-08-21 12:29:47 -0700 | [diff] [blame] | 1225 | |
| 1226 | /* Validate the coordinates are well-ordered */ |
| 1227 | |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1228 | if (min_x > max_x) |
Alyssa Rosenzweig | ded9a68 | 2019-08-21 12:29:47 -0700 | [diff] [blame] | 1229 | pandecode_msg("XXX: misordered X coordinates (%u > %u)\n", min_x, max_x); |
| 1230 | |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1231 | if (min_y > max_y) |
Alyssa Rosenzweig | ded9a68 | 2019-08-21 12:29:47 -0700 | [diff] [blame] | 1232 | pandecode_msg("XXX: misordered X coordinates (%u > %u)\n", min_x, max_x); |
| 1233 | |
| 1234 | /* Validate the coordinates fit inside the framebuffer. We use floor, |
| 1235 | * rather than ceil, for the max coordinates, since the tile |
| 1236 | * coordinates for something like an 800x600 framebuffer will actually |
| 1237 | * resolve to 800x608, which would otherwise trigger a Y-overflow */ |
| 1238 | |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1239 | if (max_x + 1 > info.width) |
Alyssa Rosenzweig | ded9a68 | 2019-08-21 12:29:47 -0700 | [diff] [blame] | 1240 | pandecode_msg("XXX: tile coordinates overflow in X direction\n"); |
| 1241 | |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1242 | if (max_y + 1 > info.height) |
Alyssa Rosenzweig | ded9a68 | 2019-08-21 12:29:47 -0700 | [diff] [blame] | 1243 | pandecode_msg("XXX: tile coordinates overflow in Y direction\n"); |
| 1244 | |
| 1245 | /* After validation, we print */ |
Vinson Lee | d9c4ec9 | 2020-09-22 17:22:12 -0700 | [diff] [blame] | 1246 | DUMP_UNPACKED(FRAGMENT_JOB_PAYLOAD, s, "Fragment Job Payload:\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1247 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1248 | /* The FBD is a tagged pointer */ |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1249 | |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1250 | unsigned tag = (s.framebuffer & MALI_FBD_TAG_MASK); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1251 | |
Alyssa Rosenzweig | f06e8f7 | 2019-08-21 12:06:50 -0700 | [diff] [blame] | 1252 | if (tag != expected_tag) |
| 1253 | 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] | 1254 | |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1255 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1256 | } |
| 1257 | |
Boris Brezillon | 9121e7d | 2020-09-08 10:39:23 +0200 | [diff] [blame] | 1258 | static void |
| 1259 | pandecode_write_value_job(const struct pandecode_mapped_memory *mem, |
| 1260 | mali_ptr job, int job_no) |
| 1261 | { |
| 1262 | struct mali_write_value_job_packed *PANDECODE_PTR_VAR(p, mem, job); |
| 1263 | pan_section_unpack(p, WRITE_VALUE_JOB, PAYLOAD, u); |
| 1264 | DUMP_SECTION(WRITE_VALUE_JOB, PAYLOAD, p, "Write Value Payload:\n"); |
| 1265 | pandecode_log("\n"); |
| 1266 | } |
| 1267 | |
Alyssa Rosenzweig | 4122f74 | 2020-02-18 07:43:51 -0500 | [diff] [blame] | 1268 | /* Entrypoint to start tracing. jc_gpu_va is the GPU address for the first job |
| 1269 | * in the chain; later jobs are found by walking the chain. Bifrost is, well, |
| 1270 | * if it's bifrost or not. GPU ID is the more finegrained ID (at some point, we |
| 1271 | * might wish to combine this with the bifrost parameter) because some details |
| 1272 | * are model-specific even within a particular architecture. Minimal traces |
| 1273 | * *only* examine the job descriptors, skipping printing entirely if there is |
| 1274 | * no faults, and only descends into the payload if there are faults. This is |
| 1275 | * useful for looking for faults without the overhead of invasive traces. */ |
| 1276 | |
Alyssa Rosenzweig | 5998646 | 2020-02-18 07:46:03 -0500 | [diff] [blame] | 1277 | void |
Alyssa Rosenzweig | 4122f74 | 2020-02-18 07:43:51 -0500 | [diff] [blame] | 1278 | 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] | 1279 | { |
Icecream95 | 01d60d3 | 2020-07-16 16:12:13 +1200 | [diff] [blame] | 1280 | pandecode_dump_file_open(); |
| 1281 | |
Alyssa Rosenzweig | 5998646 | 2020-02-18 07:46:03 -0500 | [diff] [blame] | 1282 | unsigned job_descriptor_number = 0; |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame] | 1283 | mali_ptr next_job = 0; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1284 | |
| 1285 | do { |
| 1286 | struct pandecode_mapped_memory *mem = |
| 1287 | pandecode_find_mapped_gpu_mem_containing(jc_gpu_va); |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1288 | |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame] | 1289 | pan_unpack(PANDECODE_PTR(mem, jc_gpu_va, struct mali_job_header_packed), |
| 1290 | JOB_HEADER, h); |
| 1291 | next_job = h.next; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1292 | |
| 1293 | int job_no = job_descriptor_number++; |
| 1294 | |
Alyssa Rosenzweig | 4122f74 | 2020-02-18 07:43:51 -0500 | [diff] [blame] | 1295 | /* If the job is good to go, skip it in minimal mode */ |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame] | 1296 | if (minimal && (h.exception_status == 0x0 || h.exception_status == 0x1)) |
Alyssa Rosenzweig | 4122f74 | 2020-02-18 07:43:51 -0500 | [diff] [blame] | 1297 | continue; |
| 1298 | |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame] | 1299 | DUMP_UNPACKED(JOB_HEADER, h, "Job Header:\n"); |
| 1300 | pandecode_log("\n"); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1301 | |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame] | 1302 | switch (h.type) { |
Boris Brezillon | 9121e7d | 2020-09-08 10:39:23 +0200 | [diff] [blame] | 1303 | case MALI_JOB_TYPE_WRITE_VALUE: |
| 1304 | pandecode_write_value_job(mem, jc_gpu_va, job_no); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1305 | break; |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1306 | |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1307 | case MALI_JOB_TYPE_TILER: |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1308 | if (bifrost) |
| 1309 | pandecode_tiler_job_bfr(&h, mem, jc_gpu_va, job_no, gpu_id); |
| 1310 | else |
| 1311 | pandecode_tiler_job_mdg(&h, mem, jc_gpu_va, job_no, gpu_id); |
| 1312 | break; |
| 1313 | |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1314 | case MALI_JOB_TYPE_VERTEX: |
| 1315 | case MALI_JOB_TYPE_COMPUTE: |
Boris Brezillon | d289209 | 2020-09-08 19:41:51 +0200 | [diff] [blame] | 1316 | pandecode_vertex_compute_geometry_job(&h, mem, jc_gpu_va, job_no, |
| 1317 | bifrost, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1318 | break; |
| 1319 | |
Alyssa Rosenzweig | 4b7056b | 2020-08-05 18:40:44 -0400 | [diff] [blame] | 1320 | case MALI_JOB_TYPE_FRAGMENT: |
Boris Brezillon | 89fafe9 | 2020-09-08 12:43:48 +0200 | [diff] [blame] | 1321 | pandecode_fragment_job(mem, jc_gpu_va, job_no, bifrost, gpu_id); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1322 | break; |
| 1323 | |
| 1324 | default: |
| 1325 | break; |
| 1326 | } |
Boris Brezillon | eb92354 | 2020-09-08 07:07:41 +0200 | [diff] [blame] | 1327 | } while ((jc_gpu_va = next_job)); |
Icecream95 | ef67218 | 2020-06-22 22:49:53 +1200 | [diff] [blame] | 1328 | |
| 1329 | pandecode_map_read_write(); |
Alyssa Rosenzweig | f611782 | 2019-02-19 05:50:14 +0000 | [diff] [blame] | 1330 | } |