From: Alyssa Rosenzweig Date: Wed, 12 Aug 2020 01:30:46 +0000 (-0400) Subject: panfrost: XMLify enum mali_format X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0c621dcf0ed21eec658e45cee395f66344ac5190;p=mesa.git panfrost: XMLify enum mali_format Note we are just handling the index part of the format. This is *not* the full format, which would include the swizzle (or v7 equivalent) and the sRGB flag. But in the interest of incremental progress, let's move this part over first and save on decoding complexity. To avoid substantial churn from prefixing FORMAT to format names, we special case the enums to avoid the prefix. This is undesirable but reduces churn, especially since format handling is slated for an overhaul soon to accomodate v7 Signed-off-by: Alyssa Rosenzweig Reviewed-by: Tomeu Vizoso Part-of: --- diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h index 75ee394bedc..5be15a5f42f 100644 --- a/src/panfrost/include/panfrost-job.h +++ b/src/panfrost/include/panfrost-job.h @@ -217,129 +217,6 @@ enum mali_channel { #define MALI_CHANNEL_FLOAT 7 #define MALI_EXTRACT_BITS(fmt) (fmt & 0x7) -enum mali_format { - /* Not all formats are in fact available, need to query dynamically to - * check. Factory settings for Juno enables only ETC2 and ASTC, no - * DXT/RGTC formats. - * */ - - /* 0x0 invalid */ - MALI_ETC2_RGB8 = MALI_FORMAT_COMPRESSED | 0x1, - MALI_ETC2_R11_UNORM = MALI_FORMAT_COMPRESSED | 0x2, - MALI_ETC2_RGBA8 = MALI_FORMAT_COMPRESSED | 0x3, - MALI_ETC2_RG11_UNORM = MALI_FORMAT_COMPRESSED | 0x4, - /* 0x5 reserved */ - MALI_NXR = MALI_FORMAT_COMPRESSED | 0x6, /* Nokia eXtended Range */ - MALI_BC1_UNORM = MALI_FORMAT_COMPRESSED | 0x7, /* DXT1 */ - MALI_BC2_UNORM = MALI_FORMAT_COMPRESSED | 0x8, /* DXT3 */ - MALI_BC3_UNORM = MALI_FORMAT_COMPRESSED | 0x9, /* DXT5 */ - MALI_BC4_UNORM = MALI_FORMAT_COMPRESSED | 0xA, /* RGTC1_UNORM */ - MALI_BC4_SNORM = MALI_FORMAT_COMPRESSED | 0xB, /* RGTC1_SNORM */ - MALI_BC5_UNORM = MALI_FORMAT_COMPRESSED | 0xC, /* RGTC2_UNORM */ - MALI_BC5_SNORM = MALI_FORMAT_COMPRESSED | 0xD, /* RGTC2_SNORM */ - MALI_BC6H_UF16 = MALI_FORMAT_COMPRESSED | 0xE, - MALI_BC6H_SF16 = MALI_FORMAT_COMPRESSED | 0xF, - MALI_BC7_UNORM = MALI_FORMAT_COMPRESSED | 0x10, - MALI_ETC2_R11_SNORM = MALI_FORMAT_COMPRESSED | 0x11, /* EAC_SNORM */ - MALI_ETC2_RG11_SNORM = MALI_FORMAT_COMPRESSED | 0x12, /* EAC_SNORM */ - MALI_ETC2_RGB8A1 = MALI_FORMAT_COMPRESSED | 0x13, - MALI_ASTC_3D_LDR = MALI_FORMAT_COMPRESSED | 0x14, - MALI_ASTC_3D_HDR = MALI_FORMAT_COMPRESSED | 0x15, - MALI_ASTC_2D_LDR = MALI_FORMAT_COMPRESSED | 0x16, - MALI_ASTC_2D_HDR = MALI_FORMAT_COMPRESSED | 0x17, - - MALI_RGB565 = MALI_FORMAT_SPECIAL | 0x0, - MALI_RGB5_X1_UNORM = MALI_FORMAT_SPECIAL | 0x1, - MALI_RGB5_A1_UNORM = MALI_FORMAT_SPECIAL | 0x2, - MALI_RGB10_A2_UNORM = MALI_FORMAT_SPECIAL | 0x3, - MALI_RGB10_A2_SNORM = MALI_FORMAT_SPECIAL | 0x5, - MALI_RGB10_A2UI = MALI_FORMAT_SPECIAL | 0x7, - MALI_RGB10_A2I = MALI_FORMAT_SPECIAL | 0x9, - - MALI_RGB332_UNORM = MALI_FORMAT_SPECIAL | 0xb, - MALI_RGB233_UNORM = MALI_FORMAT_SPECIAL | 0xc, - - MALI_Z24X8_UNORM = MALI_FORMAT_SPECIAL | 0xd, - MALI_R32_FIXED = MALI_FORMAT_SPECIAL | 0x11, - MALI_RG32_FIXED = MALI_FORMAT_SPECIAL | 0x12, - MALI_RGB32_FIXED = MALI_FORMAT_SPECIAL | 0x13, - MALI_RGBA32_FIXED = MALI_FORMAT_SPECIAL | 0x14, - MALI_R11F_G11F_B10F = MALI_FORMAT_SPECIAL | 0x19, - MALI_R9F_G9F_B9F_E5F = MALI_FORMAT_SPECIAL | 0x1b, - /* Only used for varyings, to indicate the transformed gl_Position */ - MALI_VARYING_POS = MALI_FORMAT_SPECIAL | 0x1e, - /* Only used for varyings, to indicate that the write should be - * discarded. - */ - MALI_VARYING_DISCARD = MALI_FORMAT_SPECIAL | 0x1f, - - MALI_R8_SNORM = MALI_FORMAT_SNORM | MALI_NR_CHANNELS(1) | MALI_CHANNEL_8, - MALI_R16_SNORM = MALI_FORMAT_SNORM | MALI_NR_CHANNELS(1) | MALI_CHANNEL_16, - MALI_R32_SNORM = MALI_FORMAT_SNORM | MALI_NR_CHANNELS(1) | MALI_CHANNEL_32, - MALI_RG8_SNORM = MALI_FORMAT_SNORM | MALI_NR_CHANNELS(2) | MALI_CHANNEL_8, - MALI_RG16_SNORM = MALI_FORMAT_SNORM | MALI_NR_CHANNELS(2) | MALI_CHANNEL_16, - MALI_RG32_SNORM = MALI_FORMAT_SNORM | MALI_NR_CHANNELS(2) | MALI_CHANNEL_32, - MALI_RGB8_SNORM = MALI_FORMAT_SNORM | MALI_NR_CHANNELS(3) | MALI_CHANNEL_8, - MALI_RGB16_SNORM = MALI_FORMAT_SNORM | MALI_NR_CHANNELS(3) | MALI_CHANNEL_16, - MALI_RGB32_SNORM = MALI_FORMAT_SNORM | MALI_NR_CHANNELS(3) | MALI_CHANNEL_32, - MALI_RGBA8_SNORM = MALI_FORMAT_SNORM | MALI_NR_CHANNELS(4) | MALI_CHANNEL_8, - MALI_RGBA16_SNORM = MALI_FORMAT_SNORM | MALI_NR_CHANNELS(4) | MALI_CHANNEL_16, - MALI_RGBA32_SNORM = MALI_FORMAT_SNORM | MALI_NR_CHANNELS(4) | MALI_CHANNEL_32, - - MALI_R8UI = MALI_FORMAT_UINT | MALI_NR_CHANNELS(1) | MALI_CHANNEL_8, - MALI_R16UI = MALI_FORMAT_UINT | MALI_NR_CHANNELS(1) | MALI_CHANNEL_16, - MALI_R32UI = MALI_FORMAT_UINT | MALI_NR_CHANNELS(1) | MALI_CHANNEL_32, - MALI_RG8UI = MALI_FORMAT_UINT | MALI_NR_CHANNELS(2) | MALI_CHANNEL_8, - MALI_RG16UI = MALI_FORMAT_UINT | MALI_NR_CHANNELS(2) | MALI_CHANNEL_16, - MALI_RG32UI = MALI_FORMAT_UINT | MALI_NR_CHANNELS(2) | MALI_CHANNEL_32, - MALI_RGB8UI = MALI_FORMAT_UINT | MALI_NR_CHANNELS(3) | MALI_CHANNEL_8, - MALI_RGB16UI = MALI_FORMAT_UINT | MALI_NR_CHANNELS(3) | MALI_CHANNEL_16, - MALI_RGB32UI = MALI_FORMAT_UINT | MALI_NR_CHANNELS(3) | MALI_CHANNEL_32, - MALI_RGBA8UI = MALI_FORMAT_UINT | MALI_NR_CHANNELS(4) | MALI_CHANNEL_8, - MALI_RGBA16UI = MALI_FORMAT_UINT | MALI_NR_CHANNELS(4) | MALI_CHANNEL_16, - MALI_RGBA32UI = MALI_FORMAT_UINT | MALI_NR_CHANNELS(4) | MALI_CHANNEL_32, - - MALI_R8_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(1) | MALI_CHANNEL_8, - MALI_R16_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(1) | MALI_CHANNEL_16, - MALI_R32_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(1) | MALI_CHANNEL_32, - MALI_R32F = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(1) | MALI_CHANNEL_FLOAT, - MALI_RG8_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(2) | MALI_CHANNEL_8, - MALI_RG16_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(2) | MALI_CHANNEL_16, - MALI_RG32_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(2) | MALI_CHANNEL_32, - MALI_RG32F = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(2) | MALI_CHANNEL_FLOAT, - MALI_RGB8_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(3) | MALI_CHANNEL_8, - MALI_RGB16_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(3) | MALI_CHANNEL_16, - MALI_RGB32_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(3) | MALI_CHANNEL_32, - MALI_RGB32F = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(3) | MALI_CHANNEL_FLOAT, - MALI_RGBA4_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(4) | MALI_CHANNEL_4, - MALI_RGBA8_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(4) | MALI_CHANNEL_8, - MALI_RGBA16_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(4) | MALI_CHANNEL_16, - MALI_RGBA32_UNORM = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(4) | MALI_CHANNEL_32, - MALI_RGBA32F = MALI_FORMAT_UNORM | MALI_NR_CHANNELS(4) | MALI_CHANNEL_FLOAT, - - MALI_R8I = MALI_FORMAT_SINT | MALI_NR_CHANNELS(1) | MALI_CHANNEL_8, - MALI_R16I = MALI_FORMAT_SINT | MALI_NR_CHANNELS(1) | MALI_CHANNEL_16, - MALI_R32I = MALI_FORMAT_SINT | MALI_NR_CHANNELS(1) | MALI_CHANNEL_32, - MALI_R16F = MALI_FORMAT_SINT | MALI_NR_CHANNELS(1) | MALI_CHANNEL_FLOAT, - MALI_RG8I = MALI_FORMAT_SINT | MALI_NR_CHANNELS(2) | MALI_CHANNEL_8, - MALI_RG16I = MALI_FORMAT_SINT | MALI_NR_CHANNELS(2) | MALI_CHANNEL_16, - MALI_RG32I = MALI_FORMAT_SINT | MALI_NR_CHANNELS(2) | MALI_CHANNEL_32, - MALI_RG16F = MALI_FORMAT_SINT | MALI_NR_CHANNELS(2) | MALI_CHANNEL_FLOAT, - MALI_RGB8I = MALI_FORMAT_SINT | MALI_NR_CHANNELS(3) | MALI_CHANNEL_8, - MALI_RGB16I = MALI_FORMAT_SINT | MALI_NR_CHANNELS(3) | MALI_CHANNEL_16, - MALI_RGB32I = MALI_FORMAT_SINT | MALI_NR_CHANNELS(3) | MALI_CHANNEL_32, - MALI_RGB16F = MALI_FORMAT_SINT | MALI_NR_CHANNELS(3) | MALI_CHANNEL_FLOAT, - MALI_RGBA8I = MALI_FORMAT_SINT | MALI_NR_CHANNELS(4) | MALI_CHANNEL_8, - MALI_RGBA16I = MALI_FORMAT_SINT | MALI_NR_CHANNELS(4) | MALI_CHANNEL_16, - MALI_RGBA32I = MALI_FORMAT_SINT | MALI_NR_CHANNELS(4) | MALI_CHANNEL_32, - MALI_RGBA16F = MALI_FORMAT_SINT | MALI_NR_CHANNELS(4) | MALI_CHANNEL_FLOAT, - - MALI_RGBA4 = MALI_FORMAT_SPECIAL2 | 0x8, - MALI_RGBA8_2 = MALI_FORMAT_SPECIAL2 | 0xd, - MALI_RGB10_A2_2 = MALI_FORMAT_SPECIAL2 | 0xe, -}; - - /* Applies to midgard1.flags_lo */ /* Should be set when the fragment shader updates the depth value. */ diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c index d103829fe5c..54f84742b71 100644 --- a/src/panfrost/lib/decode.c +++ b/src/panfrost/lib/decode.c @@ -334,125 +334,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 - static char *pandecode_attr_mode_short(enum mali_attr_mode mode) { switch(mode) { @@ -918,33 +799,6 @@ pandecode_validate_format_swizzle(enum mali_format fmt, unsigned swizzle) 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) { @@ -1580,8 +1434,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"); @@ -1743,8 +1596,7 @@ pandecode_attribute_meta(int job_no, int count, const struct mali_vertex_tiler_p 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); + pandecode_log_cont("%s %s_%u", mali_format_as_str(attr_meta->format), prefix, attr_meta->index); if (attr_meta->src_offset) pandecode_log_cont("[%u]", attr_meta->src_offset); diff --git a/src/panfrost/lib/gen_pack.py b/src/panfrost/lib/gen_pack.py index c192b50821a..0266838f623 100644 --- a/src/panfrost/lib/gen_pack.py +++ b/src/panfrost/lib/gen_pack.py @@ -592,11 +592,16 @@ class Parser(object): self.emit_unpack_function(self.struct, self.group) self.emit_print_function(self.struct, self.group) + def enum_prefix(self, name): + return + def emit_enum(self): e_name = enum_name(self.enum) + prefix = e_name if self.enum != 'Format' else global_prefix print('enum {} {{'.format(e_name)) + for value in self.values: - name = '{}_{}'.format(e_name, value.name) + name = '{}_{}'.format(prefix, value.name) name = safe_name(name).upper() print(' % -36s = %6d,' % (name, value.value)) print('};\n') @@ -605,7 +610,7 @@ class Parser(object): print("{}_as_str(enum {} imm)\n{{".format(e_name.lower(), e_name)) print(" switch (imm) {") for value in self.values: - name = '{}_{}'.format(e_name, value.name) + name = '{}_{}'.format(prefix, value.name) name = safe_name(name).upper() print(' case {}: return "{}";'.format(name, value.name)) print(' default: return "XXX: INVALID";') diff --git a/src/panfrost/lib/midgard.xml b/src/panfrost/lib/midgard.xml index 97199b5a032..baa251e8b7c 100644 --- a/src/panfrost/lib/midgard.xml +++ b/src/panfrost/lib/midgard.xml @@ -45,6 +45,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +