Mesa (main): panfrost: Use ASTC 2D enums
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Sep 30 14:40:01 UTC 2021
Module: Mesa
Branch: main
Commit: a1c6a150123d680de148042a15924d4df39bdd38
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1c6a150123d680de148042a15924d4df39bdd38
Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date: Thu Sep 30 09:35:23 2021 -0400
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 at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12814>
---
src/panfrost/lib/pan_texture.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c
index 17f14dd689b..884d52f12bc 100644
--- a/src/panfrost/lib/pan_texture.c
+++ b/src/panfrost/lib/pan_texture.c
@@ -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;
}
More information about the mesa-commit
mailing list