panfrost: Use ASTC 2D enums

Rather than manipulating the bits to do the mapping, use a dead simple
switch() with the enum definition.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12814>
This commit is contained in:
Alyssa Rosenzweig 2021-09-30 09:35:23 -04:00 committed by Marge Bot
parent 3d28039b3e
commit a1c6a15012

View file

@ -354,11 +354,18 @@ pan_iview_get_surface(const struct pan_image_view *iview,
* 6-bit tag on the payload pointer. Map the block size for a single dimension.
*/
static unsigned
panfrost_astc_stretch(unsigned dim)
static inline enum mali_astc_2d_dimension
panfrost_astc_dim_2d(unsigned dim)
{
assert(dim >= 4 && dim <= 12);
return MIN2(dim, 11) - 4;
switch (dim) {
case 4: return MALI_ASTC_2D_DIMENSION_4;
case 5: return MALI_ASTC_2D_DIMENSION_5;
case 6: return MALI_ASTC_2D_DIMENSION_6;
case 8: return MALI_ASTC_2D_DIMENSION_8;
case 10: return MALI_ASTC_2D_DIMENSION_10;
case 12: return MALI_ASTC_2D_DIMENSION_12;
default: unreachable("Invalid ASTC dimension");
}
}
/* Texture addresses are tagged with information about compressed formats.
@ -397,8 +404,8 @@ panfrost_compression_tag(const struct util_format_description *desc,
return flags;
} else if (desc->layout == UTIL_FORMAT_LAYOUT_ASTC) {
return (panfrost_astc_stretch(desc->block.height) << 3) |
panfrost_astc_stretch(desc->block.width);
return (panfrost_astc_dim_2d(desc->block.height) << 3) |
panfrost_astc_dim_2d(desc->block.width);
} else {
return 0;
}