X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fpanfrost%2Flib%2Fdecode.c;h=e51c7fb8289fd20a719819b38f370264aee2b174;hb=01d12c353e2d6cbfff11c566940b3f68f7ac11b3;hp=b218595560b9743bfdb9bbc139d15ace70b9b515;hpb=ad0b32cdbd512dd56c66426789c7b801a5db8a4f;p=mesa.git diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c index b218595560b..e51c7fb8289 100644 --- a/src/panfrost/lib/decode.c +++ b/src/panfrost/lib/decode.c @@ -64,9 +64,15 @@ static void pandecode_swizzle(unsigned swizzle, enum mali_format format); MALI_ ## T ## _print(pandecode_dump_stream, &temp, indent * 2); \ } +#define MAP_ADDR(T, addr, cl) \ + const uint8_t *cl = 0; \ + { \ + struct pandecode_mapped_memory *mapped_mem = pandecode_find_mapped_gpu_mem_containing(addr); \ + cl = pandecode_fetch_gpu_mem(mapped_mem, addr, MALI_ ## T ## _LENGTH); \ + } + #define DUMP_ADDR(title, T, addr, indent) {\ - struct pandecode_mapped_memory *mapped_mem = pandecode_find_mapped_gpu_mem_containing(addr); \ - const uint8_t *cl = pandecode_fetch_gpu_mem(mapped_mem, addr, MALI_ ## T ## _LENGTH); \ + MAP_ADDR(T, addr, cl) \ DUMP_CL(title, T, cl, indent); \ } @@ -334,214 +340,6 @@ static const struct pandecode_flag_info sfbd_unk2_info [] = { }; #undef FLAG_INFO -#define DEFINE_CASE(name) case MALI_## name: return "MALI_" #name -static char *pandecode_format(enum mali_format format) -{ - static char unk_format_str[10]; - - switch (format) { - DEFINE_CASE(ETC2_RGB8); - DEFINE_CASE(ETC2_R11_UNORM); - DEFINE_CASE(ETC2_RGBA8); - DEFINE_CASE(ETC2_RG11_UNORM); - DEFINE_CASE(ETC2_R11_SNORM); - DEFINE_CASE(ETC2_RG11_SNORM); - DEFINE_CASE(ETC2_RGB8A1); - DEFINE_CASE(NXR); - DEFINE_CASE(BC1_UNORM); - DEFINE_CASE(BC2_UNORM); - DEFINE_CASE(BC3_UNORM); - DEFINE_CASE(BC4_UNORM); - DEFINE_CASE(BC4_SNORM); - DEFINE_CASE(BC5_UNORM); - DEFINE_CASE(BC5_SNORM); - DEFINE_CASE(BC6H_UF16); - DEFINE_CASE(BC6H_SF16); - DEFINE_CASE(BC7_UNORM); - DEFINE_CASE(ASTC_3D_LDR); - DEFINE_CASE(ASTC_3D_HDR); - DEFINE_CASE(ASTC_2D_LDR); - DEFINE_CASE(ASTC_2D_HDR); - DEFINE_CASE(RGB565); - DEFINE_CASE(RGB5_X1_UNORM); - DEFINE_CASE(RGB5_A1_UNORM); - DEFINE_CASE(RGB10_A2_UNORM); - DEFINE_CASE(RGB10_A2_SNORM); - DEFINE_CASE(RGB10_A2UI); - DEFINE_CASE(RGB10_A2I); - DEFINE_CASE(RGB332_UNORM); - DEFINE_CASE(RGB233_UNORM); - DEFINE_CASE(Z24X8_UNORM); - DEFINE_CASE(R32_FIXED); - DEFINE_CASE(RG32_FIXED); - DEFINE_CASE(RGB32_FIXED); - DEFINE_CASE(RGBA32_FIXED); - DEFINE_CASE(R11F_G11F_B10F); - DEFINE_CASE(R9F_G9F_B9F_E5F); - DEFINE_CASE(VARYING_POS); - DEFINE_CASE(VARYING_DISCARD); - - DEFINE_CASE(R8_SNORM); - DEFINE_CASE(R16_SNORM); - DEFINE_CASE(R32_SNORM); - DEFINE_CASE(RG8_SNORM); - DEFINE_CASE(RG16_SNORM); - DEFINE_CASE(RG32_SNORM); - DEFINE_CASE(RGB8_SNORM); - DEFINE_CASE(RGB16_SNORM); - DEFINE_CASE(RGB32_SNORM); - DEFINE_CASE(RGBA8_SNORM); - DEFINE_CASE(RGBA16_SNORM); - DEFINE_CASE(RGBA32_SNORM); - - DEFINE_CASE(R8UI); - DEFINE_CASE(R16UI); - DEFINE_CASE(R32UI); - DEFINE_CASE(RG8UI); - DEFINE_CASE(RG16UI); - DEFINE_CASE(RG32UI); - DEFINE_CASE(RGB8UI); - DEFINE_CASE(RGB16UI); - DEFINE_CASE(RGB32UI); - DEFINE_CASE(RGBA8UI); - DEFINE_CASE(RGBA16UI); - DEFINE_CASE(RGBA32UI); - - DEFINE_CASE(R8_UNORM); - DEFINE_CASE(R16_UNORM); - DEFINE_CASE(R32_UNORM); - DEFINE_CASE(R32F); - DEFINE_CASE(RG8_UNORM); - DEFINE_CASE(RG16_UNORM); - DEFINE_CASE(RG32_UNORM); - DEFINE_CASE(RG32F); - DEFINE_CASE(RGB8_UNORM); - DEFINE_CASE(RGB16_UNORM); - DEFINE_CASE(RGB32_UNORM); - DEFINE_CASE(RGB32F); - DEFINE_CASE(RGBA4_UNORM); - DEFINE_CASE(RGBA8_UNORM); - DEFINE_CASE(RGBA16_UNORM); - DEFINE_CASE(RGBA32_UNORM); - DEFINE_CASE(RGBA32F); - - DEFINE_CASE(R8I); - DEFINE_CASE(R16I); - DEFINE_CASE(R32I); - DEFINE_CASE(RG8I); - DEFINE_CASE(R16F); - DEFINE_CASE(RG16I); - DEFINE_CASE(RG32I); - DEFINE_CASE(RG16F); - DEFINE_CASE(RGB8I); - DEFINE_CASE(RGB16I); - DEFINE_CASE(RGB32I); - DEFINE_CASE(RGB16F); - DEFINE_CASE(RGBA8I); - DEFINE_CASE(RGBA16I); - DEFINE_CASE(RGBA32I); - DEFINE_CASE(RGBA16F); - - DEFINE_CASE(RGBA4); - DEFINE_CASE(RGBA8_2); - DEFINE_CASE(RGB10_A2_2); - default: - snprintf(unk_format_str, sizeof(unk_format_str), "MALI_0x%02x", format); - return unk_format_str; - } -} - -#undef DEFINE_CASE - -#define DEFINE_CASE(name) case MALI_MSAA_ ## name: return "MALI_MSAA_" #name -static char * -pandecode_msaa_mode(enum mali_msaa_mode mode) -{ - switch (mode) { - DEFINE_CASE(SINGLE); - DEFINE_CASE(AVERAGE); - DEFINE_CASE(MULTIPLE); - DEFINE_CASE(LAYERED); - default: - unreachable("Impossible"); - return ""; - } -} -#undef DEFINE_CASE - -static char *pandecode_attr_mode_short(enum mali_attr_mode mode) -{ - switch(mode) { - /* TODO: Combine to just "instanced" once this can be done - * unambiguously in all known cases */ - case MALI_ATTR_POT_DIVIDE: - return "instanced_pot"; - case MALI_ATTR_MODULO: - return "instanced_mod"; - case MALI_ATTR_NPOT_DIVIDE: - return "instanced_npot"; - case MALI_ATTR_IMAGE: - return "image"; - default: - pandecode_msg("XXX: invalid attribute mode %X\n", mode); - return ""; - } -} - -static const char * -pandecode_special_record(uint64_t v, bool* attribute) -{ - switch(v) { - case MALI_ATTR_VERTEXID: - *attribute = true; - return "gl_VertexID"; - case MALI_ATTR_INSTANCEID: - *attribute = true; - return "gl_InstanceID"; - case MALI_VARYING_FRAG_COORD: - return "gl_FragCoord"; - case MALI_VARYING_FRONT_FACING: - return "gl_FrontFacing"; - case MALI_VARYING_POINT_COORD: - return "gl_PointCoord"; - default: - pandecode_msg("XXX: invalid special record %" PRIx64 "\n", v); - return ""; - } -} - -#define DEFINE_CASE(name) case MALI_BLOCK_## name: return "MALI_BLOCK_" #name -static char * -pandecode_block_format(enum mali_block_format fmt) -{ - switch (fmt) { - DEFINE_CASE(TILED); - DEFINE_CASE(UNKNOWN); - DEFINE_CASE(LINEAR); - DEFINE_CASE(AFBC); - - default: - unreachable("Invalid case"); - } -} -#undef DEFINE_CASE - -#define DEFINE_CASE(name) case MALI_EXCEPTION_ACCESS_## name: return ""#name -static char * -pandecode_exception_access(unsigned access) -{ - switch (access) { - DEFINE_CASE(NONE); - DEFINE_CASE(EXECUTE); - DEFINE_CASE(READ); - DEFINE_CASE(WRITE); - - default: - unreachable("Invalid case"); - } -} -#undef DEFINE_CASE - /* Midgard's tiler descriptor is embedded within the * larger FBD */ @@ -595,9 +393,6 @@ pandecode_midgard_tiler_descriptor( MEMORY_PROP(t, heap_start); assert(t->heap_end >= t->heap_start); - struct pandecode_mapped_memory *heap = - pandecode_find_mapped_gpu_mem_containing(t->heap_start); - unsigned heap_size = t->heap_end - t->heap_start; /* Tiling is enabled with a special flag */ @@ -607,13 +402,6 @@ pandecode_midgard_tiler_descriptor( bool tiling_enabled = hierarchy_mask; if (tiling_enabled) { - /* When tiling is enabled, the heap should be a tight fit */ - unsigned heap_offset = t->heap_start - heap->gpu_va; - if ((heap_offset + heap_size) != heap->length) { - pandecode_msg("XXX: heap size %u (expected %zu)\n", - heap_size, heap->length - heap_offset); - } - /* We should also have no other flags */ if (tiler_flags) pandecode_msg("XXX: unexpected tiler %X\n", tiler_flags); @@ -718,7 +506,7 @@ pandecode_sfbd_format(struct mali_sfbd_format format) pandecode_log_decoded_flags(sfbd_unk2_info, format.unk2); pandecode_log_cont(",\n"); - pandecode_prop("block = %s", pandecode_block_format(format.block)); + pandecode_prop("block = %s", mali_block_format_as_str(format.block)); pandecode_prop("unk3 = 0x%" PRIx32, format.unk3); @@ -922,12 +710,12 @@ static unsigned pandecode_access_mask_from_channel_swizzle(unsigned swizzle) { unsigned mask = 0; - assert(MALI_CHANNEL_RED == 0); + assert(MALI_CHANNEL_R == 0); for (unsigned c = 0; c < 4; ++c) { enum mali_channel chan = (swizzle >> (3*c)) & 0x7; - if (chan <= MALI_CHANNEL_ALPHA) + if (chan <= MALI_CHANNEL_A) mask |= (1 << chan); } @@ -956,42 +744,15 @@ pandecode_validate_format_swizzle(enum mali_format fmt, unsigned swizzle) * useless printing for the defaults */ unsigned default_swizzles[4] = { - MALI_CHANNEL_RED | (MALI_CHANNEL_ZERO << 3) | (MALI_CHANNEL_ZERO << 6) | (MALI_CHANNEL_ONE << 9), - MALI_CHANNEL_RED | (MALI_CHANNEL_GREEN << 3) | (MALI_CHANNEL_ZERO << 6) | (MALI_CHANNEL_ONE << 9), - MALI_CHANNEL_RED | (MALI_CHANNEL_GREEN << 3) | (MALI_CHANNEL_BLUE << 6) | (MALI_CHANNEL_ONE << 9), - MALI_CHANNEL_RED | (MALI_CHANNEL_GREEN << 3) | (MALI_CHANNEL_BLUE << 6) | (MALI_CHANNEL_ALPHA << 9) + MALI_CHANNEL_R | (MALI_CHANNEL_0 << 3) | (MALI_CHANNEL_0 << 6) | (MALI_CHANNEL_1 << 9), + MALI_CHANNEL_R | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_0 << 6) | (MALI_CHANNEL_1 << 9), + MALI_CHANNEL_R | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_B << 6) | (MALI_CHANNEL_1 << 9), + MALI_CHANNEL_R | (MALI_CHANNEL_G << 3) | (MALI_CHANNEL_B << 6) | (MALI_CHANNEL_A << 9) }; return (swizzle == default_swizzles[nr_comp - 1]); } -/* Maps MALI_RGBA32F to rgba32f, etc */ - -static void -pandecode_format_short(enum mali_format fmt, bool srgb) -{ - /* We want a type-like format, so cut off the initial MALI_ */ - char *format = pandecode_format(fmt); - format += strlen("MALI_"); - - unsigned len = strlen(format); - char *lower_format = calloc(1, len + 1); - - for (unsigned i = 0; i < len; ++i) - lower_format[i] = tolower(format[i]); - - /* Sanity check sRGB flag is applied to RGB, per the name */ - if (srgb && lower_format[0] != 'r') - pandecode_msg("XXX: sRGB applied to non-colour format\n"); - - /* Just prefix with an s, so you get formats like srgba8_unorm */ - if (srgb) - pandecode_log_cont("s"); - - pandecode_log_cont("%s", lower_format); - free(lower_format); -} - static void pandecode_swizzle(unsigned swizzle, enum mali_format format) { @@ -1010,7 +771,7 @@ pandecode_swizzle(unsigned swizzle, enum mali_format format) for (unsigned c = 0; c < 4; ++c) { enum mali_channel chan = (swizzle >> (3 * c)) & 0x7; - if (chan >= MALI_CHANNEL_RESERVED_0) { + if (chan > MALI_CHANNEL_1) { pandecode_log("XXX: invalid swizzle channel %d\n", chan); continue; } @@ -1029,7 +790,7 @@ pandecode_rt_format(struct mali_rt_format format) pandecode_prop("unk3 = 0x%" PRIx32, format.unk3); pandecode_prop("unk4 = 0x%" PRIx32, format.unk4); - pandecode_prop("block = %s", pandecode_block_format(format.block)); + pandecode_prop("block = %s", mali_block_format_as_str(format.block)); /* TODO: Map formats so we can check swizzles and print nicely */ pandecode_log("swizzle"); @@ -1043,7 +804,7 @@ pandecode_rt_format(struct mali_rt_format format) pandecode_log_decoded_flags(mfbd_fmt_flag_info, format.flags); pandecode_log_cont(",\n"); - pandecode_prop("msaa = %s", pandecode_msaa_mode(format.msaa)); + pandecode_prop("msaa = %s", mali_msaa_as_str(format.msaa)); /* In theory, the no_preload bit can be cleared to enable MFBD preload, * which is a faster hardware-based alternative to the wallpaper method @@ -1080,7 +841,7 @@ pandecode_render_target(uint64_t gpu_va, unsigned job_no, const struct mali_fram pandecode_rt_format(rt->format); - if (rt->format.block == MALI_BLOCK_AFBC) { + if (rt->format.block == MALI_BLOCK_FORMAT_AFBC) { pandecode_log(".afbc = {\n"); pandecode_indent++; @@ -1261,10 +1022,10 @@ pandecode_mfbd_bfr(uint64_t gpu_va, int job_no, bool is_fragment, bool is_comput pandecode_log_decoded_flags(mfbd_extra_flag_lo_info, fbx->flags_lo); pandecode_log_cont(",\n"); - pandecode_prop("zs_block = %s", pandecode_block_format(fbx->zs_block)); + pandecode_prop("zs_block = %s", mali_block_format_as_str(fbx->zs_block)); pandecode_prop("zs_samples = MALI_POSITIVE(%u)", fbx->zs_samples + 1); - if (fbx->zs_block == MALI_BLOCK_AFBC) { + if (fbx->zs_block == MALI_BLOCK_FORMAT_AFBC) { pandecode_log(".ds_afbc = {\n"); pandecode_indent++; @@ -1343,108 +1104,12 @@ pandecode_mfbd_bfr(uint64_t gpu_va, int job_no, bool is_fragment, bool is_comput return info; } -/* Just add a comment decoding the shift/odd fields forming the padded vertices - * count */ - -static void -pandecode_padded_vertices(unsigned shift, unsigned k) -{ - unsigned odd = 2*k + 1; - unsigned pot = 1 << shift; - pandecode_msg("padded_num_vertices = %d\n", odd * pot); -} - -/* Given a magic divisor, recover what we were trying to divide by. - * - * Let m represent the magic divisor. By definition, m is an element on Z, whre - * 0 <= m < 2^N, for N bits in m. - * - * Let q represent the number we would like to divide by. - * - * By definition of a magic divisor for N-bit unsigned integers (a number you - * multiply by to magically get division), m is a number such that: - * - * (m * x) & (2^N - 1) = floor(x/q). - * for all x on Z where 0 <= x < 2^N - * - * Ignore the case where any of the above values equals zero; it is irrelevant - * for our purposes (instanced arrays). - * - * Choose x = q. Then: - * - * (m * x) & (2^N - 1) = floor(x/q). - * (m * q) & (2^N - 1) = floor(q/q). - * - * floor(q/q) = floor(1) = 1, therefore: - * - * (m * q) & (2^N - 1) = 1 - * - * Recall the identity that the bitwise AND of one less than a power-of-two - * equals the modulo with that power of two, i.e. for all x: - * - * x & (2^N - 1) = x % N - * - * Therefore: - * - * mq % (2^N) = 1 - * - * By definition, a modular multiplicative inverse of a number m is the number - * q such that with respect to a modulos M: - * - * mq % M = 1 - * - * Therefore, q is the modular multiplicative inverse of m with modulus 2^N. - * - */ - -static void -pandecode_magic_divisor(uint32_t magic, unsigned shift, unsigned orig_divisor, unsigned extra) -{ -#if 0 - /* Compute the modular inverse of `magic` with respect to 2^(32 - - * shift) the most lame way possible... just repeatedly add. - * Asymptoptically slow but nobody cares in practice, unless you have - * massive numbers of vertices or high divisors. */ - - unsigned inverse = 0; - - /* Magic implicitly has the highest bit set */ - magic |= (1 << 31); - - /* Depending on rounding direction */ - if (extra) - magic++; - - for (;;) { - uint32_t product = magic * inverse; - - if (shift) { - product >>= shift; - } - - if (product == 1) - break; - - ++inverse; - } - - pandecode_msg("dividing by %d (maybe off by two)\n", inverse); - - /* Recall we're supposed to divide by (gl_level_divisor * - * padded_num_vertices) */ - - unsigned padded_num_vertices = inverse / orig_divisor; - - pandecode_msg("padded_num_vertices = %d\n", padded_num_vertices); -#endif -} - static void pandecode_attributes(const struct pandecode_mapped_memory *mem, mali_ptr addr, int job_no, char *suffix, int count, bool varying, enum mali_job_type job_type) { - char *prefix = varying ? "varying" : "attribute"; + char *prefix = varying ? "Varying" : "Attribute"; assert(addr); if (!count) { @@ -1452,116 +1117,21 @@ pandecode_attributes(const struct pandecode_mapped_memory *mem, return; } - union mali_attr *attr = pandecode_fetch_gpu_mem(mem, addr, sizeof(union mali_attr) * count); + MAP_ADDR(ATTRIBUTE_BUFFER, addr, cl); for (int i = 0; i < count; ++i) { - /* First, check for special records */ - if (attr[i].elements < MALI_RECORD_SPECIAL) { - if (attr[i].size) - pandecode_msg("XXX: tripped size=%d\n", attr[i].size); - - if (attr[i].stride) { - /* gl_InstanceID passes a magic divisor in the - * stride field to divide by the padded vertex - * count. No other records should do so, so - * stride should otherwise be zero. Note that - * stride in the usual attribute sense doesn't - * apply to special records. */ - - bool has_divisor = attr[i].elements == MALI_ATTR_INSTANCEID; - - pandecode_log_cont("/* %smagic divisor = %X */ ", - has_divisor ? "" : "XXX: ", attr[i].stride); - } - - if (attr[i].shift || attr[i].extra_flags) { - /* Attributes use these fields for - * instancing/padding/etc type issues, but - * varyings don't */ - - pandecode_log_cont("/* %sshift=%d, extra=%d */ ", - varying ? "XXX: " : "", - attr[i].shift, attr[i].extra_flags); - } - - /* Print the special record name */ - bool attribute = false; - pandecode_log("%s_%d = %s;\n", prefix, i, pandecode_special_record(attr[i].elements, &attribute)); - - /* Sanity check */ - if (attribute == varying) - pandecode_msg("XXX: mismatched special record\n"); - - continue; - } - - enum mali_attr_mode mode = attr[i].elements & 7; - - if (mode == MALI_ATTR_UNUSED) - pandecode_msg("XXX: unused attribute record\n"); - - /* For non-linear records, we need to print the type of record */ - if (mode != MALI_ATTR_LINEAR) - pandecode_log_cont("%s ", pandecode_attr_mode_short(mode)); - - /* Print the name to link with attr_meta */ - pandecode_log_cont("%s_%d", prefix, i); - - /* Print the stride and size */ - pandecode_log_cont("<%u>[%u]", attr[i].stride, attr[i].size); - - /* TODO: Sanity check the quotient itself. It must be equal to - * (or be greater than, if the driver added padding) the padded - * vertex count. */ - - /* Finally, print the pointer */ - mali_ptr raw_elements = attr[i].elements & ~7; - char *a = pointer_as_memory_reference(raw_elements); - pandecode_log_cont(" = (%s);\n", a); - free(a); + fprintf(pandecode_dump_stream, "%s\n", prefix); - /* Check the pointer */ - pandecode_validate_buffer(raw_elements, attr[i].size); + struct MALI_ATTRIBUTE_BUFFER temp; + MALI_ATTRIBUTE_BUFFER_unpack(cl + i * MALI_ATTRIBUTE_BUFFER_LENGTH, &temp); + MALI_ATTRIBUTE_BUFFER_print(pandecode_dump_stream, &temp, 2); - /* shift/extra_flags exist only for instanced */ - if (attr[i].shift | attr[i].extra_flags) { - /* These are set to random values by the blob for - * varyings, most likely a symptom of uninitialized - * memory where the hardware masked the bug. As such we - * put this at a warning, not an error. */ - - if (mode == MALI_ATTR_LINEAR) - pandecode_msg("warn: instancing fields set for linear\n"); - - pandecode_prop("shift = %d", attr[i].shift); - pandecode_prop("extra_flags = %d", attr[i].extra_flags); - } - - /* Decode further where possible */ - - if (mode == MALI_ATTR_MODULO) { - pandecode_padded_vertices( - attr[i].shift, - attr[i].extra_flags); - } - - if (mode == MALI_ATTR_NPOT_DIVIDE) { - i++; - pandecode_log("{\n"); - pandecode_indent++; - pandecode_prop("unk = 0x%x", attr[i].unk); - pandecode_prop("magic_divisor = 0x%08x", attr[i].magic_divisor); - if (attr[i].zero != 0) - pandecode_prop("XXX: zero tripped (0x%x)\n", attr[i].zero); - pandecode_prop("divisor = %d", attr[i].divisor); - pandecode_magic_divisor(attr[i].magic_divisor, attr[i - 1].shift, attr[i].divisor, attr[i - 1].extra_flags); - pandecode_indent--; - pandecode_log("}, \n"); + if (temp.type == MALI_ATTRIBUTE_TYPE_1D_NPOT_DIVISOR) { + struct MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT temp2; + MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT_unpack(cl + (i + 1) * MALI_ATTRIBUTE_BUFFER_LENGTH, &temp2); + MALI_ATTRIBUTE_BUFFER_CONTINUATION_NPOT_print(pandecode_dump_stream, &temp2, 2); } - } - - pandecode_log("\n"); } static mali_ptr @@ -1627,8 +1197,7 @@ pandecode_bifrost_blend(void *descs, int job_no, int rt_no) pandecode_prop("unk2 = 0x%" PRIx16, b->unk2); pandecode_prop("index = 0x%" PRIx16, b->index); - pandecode_log(".format = "); - pandecode_format_short(b->format, false); + pandecode_log(".format = %s", mali_format_as_str(b->format)); pandecode_swizzle(b->swizzle, b->format); pandecode_log_cont(",\n"); @@ -1731,79 +1300,13 @@ pandecode_midgard_blend_mrt(void *descs, int job_no, int rt_no) static int pandecode_attribute_meta(int job_no, int count, const struct mali_vertex_tiler_postfix *v, bool varying, char *suffix) { - char base[128]; - char *prefix = varying ? "varying" : "attribute"; - unsigned max_index = 0; - snprintf(base, sizeof(base), "%s_meta", prefix); - - struct mali_attr_meta *attr_meta; + const char *prefix = varying ? "Varying" : "Attribute"; mali_ptr p = varying ? v->varying_meta : v->attribute_meta; - struct pandecode_mapped_memory *attr_mem = pandecode_find_mapped_gpu_mem_containing(p); - - for (int i = 0; i < count; ++i, p += sizeof(struct mali_attr_meta)) { - attr_meta = pandecode_fetch_gpu_mem(attr_mem, p, - sizeof(*attr_mem)); - - /* If the record is discard, it should be zero for everything else */ - - if (attr_meta->format == MALI_VARYING_DISCARD) { - uint64_t zero = - attr_meta->index | - attr_meta->unknown1 | - attr_meta->unknown3 | - attr_meta->src_offset; - - if (zero) - pandecode_msg("XXX: expected empty record for varying discard\n"); - - /* We want to look for a literal 0000 swizzle -- this - * is not encoded with all zeroes, however */ - - enum mali_channel z = MALI_CHANNEL_ZERO; - unsigned zero_swizzle = z | (z << 3) | (z << 6) | (z << 9); - bool good_swizzle = attr_meta->swizzle == zero_swizzle; - - if (!good_swizzle) - pandecode_msg("XXX: expected zero swizzle for discard\n"); - - if (!varying) - pandecode_msg("XXX: cannot discard attribute\n"); - - /* If we're all good, omit the record */ - if (!zero && varying && good_swizzle) { - pandecode_log("/* discarded varying */\n"); - continue; - } - } - - if (attr_meta->index > max_index) - max_index = attr_meta->index; - - if (attr_meta->unknown1 != 0x2) { - pandecode_msg("XXX: expected unknown1 = 0x2\n"); - pandecode_prop("unknown1 = 0x%" PRIx64, (u64) attr_meta->unknown1); - } - - if (attr_meta->unknown3) { - pandecode_msg("XXX: unexpected unknown3 set\n"); - pandecode_prop("unknown3 = 0x%" PRIx64, (u64) attr_meta->unknown3); - } - - pandecode_format_short(attr_meta->format, false); - pandecode_log_cont(" %s_%u", prefix, attr_meta->index); - - if (attr_meta->src_offset) - pandecode_log_cont("[%u]", attr_meta->src_offset); - - pandecode_swizzle(attr_meta->swizzle, attr_meta->format); - - pandecode_log_cont(";\n"); - } - - pandecode_log("\n"); + for (int i = 0; i < count; ++i, p += MALI_ATTRIBUTE_LENGTH) + DUMP_ADDR(prefix, ATTRIBUTE, p, 1); - return count ? (max_index + 1) : 0; + return count; } /* return bits [lo, hi) of word */ @@ -2894,7 +2397,7 @@ pandecode_jc(mali_ptr jc_gpu_va, bool bifrost, unsigned gpu_id, bool minimal) pandecode_prop("exception_status = %x (source ID: 0x%x access: %s exception: 0x%x)", h->exception_status, (h->exception_status >> 16) & 0xFFFF, - pandecode_exception_access((h->exception_status >> 8) & 0x3), + mali_exception_access_as_str((h->exception_status >> 8) & 0x3), h->exception_status & 0xFF); if (h->first_incomplete_task)