From e26ffda2b9ab00c0a4f231c866481a0a19954e03 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 30 Sep 2021 09:55:25 -0400 Subject: [PATCH] panfrost: Encode 3D ASTC dimensions Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/lib/pan_texture.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c index 884d52f12bc..08678bdef35 100644 --- a/src/panfrost/lib/pan_texture.c +++ b/src/panfrost/lib/pan_texture.c @@ -368,6 +368,18 @@ panfrost_astc_dim_2d(unsigned dim) } } +static inline enum mali_astc_3d_dimension +panfrost_astc_dim_3d(unsigned dim) +{ + switch (dim) { + case 3: return MALI_ASTC_3D_DIMENSION_3; + case 4: return MALI_ASTC_3D_DIMENSION_4; + case 5: return MALI_ASTC_3D_DIMENSION_5; + case 6: return MALI_ASTC_3D_DIMENSION_6; + default: unreachable("Invalid ASTC dimension"); + } +} + /* Texture addresses are tagged with information about compressed formats. * AFBC uses a bit for whether the colorspace transform is enabled (RGB and * RGBA only). @@ -404,8 +416,14 @@ panfrost_compression_tag(const struct util_format_description *desc, return flags; } else if (desc->layout == UTIL_FORMAT_LAYOUT_ASTC) { - return (panfrost_astc_dim_2d(desc->block.height) << 3) | - panfrost_astc_dim_2d(desc->block.width); + if (desc->block.depth > 1) { + return (panfrost_astc_dim_3d(desc->block.depth) << 4) | + (panfrost_astc_dim_3d(desc->block.height) << 2) | + panfrost_astc_dim_3d(desc->block.width); + } else { + return (panfrost_astc_dim_2d(desc->block.height) << 3) | + panfrost_astc_dim_2d(desc->block.width); + } } else { return 0; }