From d5a9cd1b7dd972e84f02396cbaa067ea59c2ff39 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 10 Jul 2020 10:17:44 -0400 Subject: [PATCH] panfrost: Add format codes for new compressed textures Compressed formats line up with CONFIG_TEX_COMPRESSED_FORMAT_ENABLE documented on https://releases.linaro.org/archive/14.07/android/images/armv8-android-juno-lsk/ None of the new formats have been seen in the wild. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/encoder/pan_format.c | 58 +++++++++++------------ src/panfrost/encoder/pan_texture.c | 2 +- src/panfrost/include/panfrost-job.h | 28 +++++++++-- src/panfrost/pandecode/pan_pretty_print.c | 17 ++++++- 4 files changed, 69 insertions(+), 36 deletions(-) diff --git a/src/panfrost/encoder/pan_format.c b/src/panfrost/encoder/pan_format.c index 67c6fba4164..549b3bea503 100644 --- a/src/panfrost/encoder/pan_format.c +++ b/src/panfrost/encoder/pan_format.c @@ -51,35 +51,35 @@ struct panfrost_format panfrost_pipe_format_table[PIPE_FORMAT_COUNT] = { [PIPE_FORMAT_ETC2_RGB8A1] = { MALI_ETC2_RGB8A1, _T }, [PIPE_FORMAT_ETC2_SRGB8A1] = { MALI_ETC2_RGB8A1, _T }, - [PIPE_FORMAT_ASTC_4x4] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_5x4] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_5x5] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_6x5] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_6x6] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_8x5] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_8x6] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_8x8] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_10x5] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_10x6] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_10x8] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_10x10] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_12x10] = { MALI_ASTC_HDR_SUPP, _T }, - [PIPE_FORMAT_ASTC_12x12] = { MALI_ASTC_HDR_SUPP, _T }, - - [PIPE_FORMAT_ASTC_4x4_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_5x4_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_5x5_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_6x5_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_6x6_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_8x5_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_8x6_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_8x8_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_10x5_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_10x6_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_10x8_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_10x10_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_12x10_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, - [PIPE_FORMAT_ASTC_12x12_SRGB] = { MALI_ASTC_SRGB_SUPP, _T }, + [PIPE_FORMAT_ASTC_4x4] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_5x4] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_5x5] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_6x5] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_6x6] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_8x5] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_8x6] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_8x8] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_10x5] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_10x6] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_10x8] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_10x10] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_12x10] = { MALI_ASTC_2D_HDR, _T }, + [PIPE_FORMAT_ASTC_12x12] = { MALI_ASTC_2D_HDR, _T }, + + [PIPE_FORMAT_ASTC_4x4_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_5x4_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_5x5_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_6x5_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_6x6_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_8x5_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_8x6_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_8x8_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_10x5_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_10x6_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_10x8_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_10x10_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_12x10_SRGB] = { MALI_ASTC_2D_LDR, _T }, + [PIPE_FORMAT_ASTC_12x12_SRGB] = { MALI_ASTC_2D_LDR, _T }, [PIPE_FORMAT_B5G6R5_UNORM] = { MALI_RGB565, _VTR }, [PIPE_FORMAT_B5G5R5X1_UNORM] = { MALI_RGB5_X1_UNORM, _VT }, [PIPE_FORMAT_R5G5B5A1_UNORM] = { MALI_RGB5_A1_UNORM, _VTR }, diff --git a/src/panfrost/encoder/pan_texture.c b/src/panfrost/encoder/pan_texture.c index 5aa74d60c2f..c270ececd45 100644 --- a/src/panfrost/encoder/pan_texture.c +++ b/src/panfrost/encoder/pan_texture.c @@ -94,7 +94,7 @@ panfrost_compression_tag( { if (layout == MALI_TEXTURE_AFBC) return desc->nr_channels >= 3; - else if (format == MALI_ASTC_HDR_SUPP || format == MALI_ASTC_SRGB_SUPP) + else if (format == MALI_ASTC_2D_LDR || format == MALI_ASTC_2D_HDR) return (panfrost_astc_stretch(desc->block.height) << 3) | panfrost_astc_stretch(desc->block.width); else diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h index 178455ca8f7..720420f8ed1 100644 --- a/src/panfrost/include/panfrost-job.h +++ b/src/panfrost/include/panfrost-job.h @@ -281,15 +281,35 @@ struct mali_channel_swizzle { #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, - MALI_ETC2_R11_SNORM = MALI_FORMAT_COMPRESSED | 0x11, - MALI_ETC2_RG11_SNORM = MALI_FORMAT_COMPRESSED | 0x12, + /* 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_SRGB_SUPP = MALI_FORMAT_COMPRESSED | 0x16, - MALI_ASTC_HDR_SUPP = MALI_FORMAT_COMPRESSED | 0x17, + 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, diff --git a/src/panfrost/pandecode/pan_pretty_print.c b/src/panfrost/pandecode/pan_pretty_print.c index 05b0d1ae4cb..23664e43958 100644 --- a/src/panfrost/pandecode/pan_pretty_print.c +++ b/src/panfrost/pandecode/pan_pretty_print.c @@ -43,8 +43,21 @@ char *pandecode_format(enum mali_format format) DEFINE_CASE(ETC2_R11_SNORM); DEFINE_CASE(ETC2_RG11_SNORM); DEFINE_CASE(ETC2_RGB8A1); - DEFINE_CASE(ASTC_SRGB_SUPP); - DEFINE_CASE(ASTC_HDR_SUPP); + 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); -- 2.30.2