From 7d27fd84d5e04773fbc06e255dba4bca48d6c60d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 29 Jan 2025 15:10:34 -0500 Subject: [PATCH] ail: report miptail stride Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/layout/layout.c | 6 ++++++ src/asahi/layout/layout.h | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/asahi/layout/layout.c b/src/asahi/layout/layout.c index d5e91b8bf04..074279eb685 100644 --- a/src/asahi/layout/layout.c +++ b/src/asahi/layout/layout.c @@ -180,6 +180,12 @@ ail_initialize_twiddled(struct ail_layout *layout) */ layout->mip_tail_first_lod = MIN2(pot_level, layout->levels); + /* Determine the stride of the miptail. Sparse arrayed images inherently + * require page-aligned layers to be able to bind individual layers. + */ + unsigned tail_offset_B = layout->level_offsets_B[layout->mip_tail_first_lod]; + layout->mip_tail_stride = align(offset_B - tail_offset_B, AIL_PAGESIZE); + /* Align layer size if we have mipmaps and one miptree is larger than one * page */ layout->page_aligned_layers = layout->levels != 1 && offset_B > AIL_PAGESIZE; diff --git a/src/asahi/layout/layout.h b/src/asahi/layout/layout.h index 274d9e378af..4b5a2acd6d3 100644 --- a/src/asahi/layout/layout.h +++ b/src/asahi/layout/layout.h @@ -124,6 +124,14 @@ struct ail_layout { */ uint32_t mip_tail_first_lod; + /** + * If the image is bound sparsely, the layer stride of the miptail. + * Conceptually, this corresponds to Vulkan imageMipTailStride. However, it + * is not actually used for imageMipTailStride due to complications with + * standard sparse block sizes. + */ + uint32_t mip_tail_stride; + /* Offset of the start of the compression metadata buffer */ uint32_t metadata_offset_B;