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;