From c2bf66ab873d96bbaa24a9e6225a1fae39361df8 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 3 Feb 2023 18:46:20 -0500 Subject: [PATCH] ail: Add layout->mipmapped_z input For 3D images, the full miptree depends on the depth of the image, in contrast to 2D arrays. We need to account for this to calculate the correct layer strides. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/layout/layout.c | 8 ++++++-- src/asahi/layout/layout.h | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/asahi/layout/layout.c b/src/asahi/layout/layout.c index 280466ed524..8ad7514c7e2 100644 --- a/src/asahi/layout/layout.c +++ b/src/asahi/layout/layout.c @@ -249,8 +249,12 @@ ail_make_miptree(struct ail_layout *layout) * allocate them all. */ if (layout->levels > 1) { - layout->levels = - util_logbase2(MAX2(layout->width_px, layout->height_px)) + 1; + unsigned major_axis_px = MAX2(layout->width_px, layout->height_px); + + if (layout->mipmapped_z) + major_axis_px = MAX2(major_axis_px, layout->depth_px); + + layout->levels = util_logbase2(major_axis_px) + 1; } assert(util_format_get_blockdepth(layout->format) == 1 && diff --git a/src/asahi/layout/layout.h b/src/asahi/layout/layout.h index d0d97a16fd1..fcb57cee8b2 100644 --- a/src/asahi/layout/layout.h +++ b/src/asahi/layout/layout.h @@ -79,6 +79,12 @@ struct ail_layout { /** Number of miplevels. 1 if no mipmapping is used. */ uint8_t levels; + /** Should this image be mipmapped along the Z-axis in addition to the X- and + * Y-axes? This should be set for API-level 3D images, but not 2D arrays or + * cubes. + */ + bool mipmapped_z; + /** Tiling mode used */ enum ail_tiling tiling;