From 8ddc527ba4eaf465b87e0670e96f6de147dec1be Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Wed, 14 Aug 2024 11:03:08 +0200 Subject: [PATCH] vk/image: Fix the view extent of uncompressed views of compressed images The view extent needs to be divided by the block width/height/depth in that case. Signed-off-by: Boris Brezillon Reviewed-by: Faith Ekstrand Part-of: --- src/vulkan/runtime/vk_image.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/vulkan/runtime/vk_image.c b/src/vulkan/runtime/vk_image.c index 4f6479010ec..09acb91be1e 100644 --- a/src/vulkan/runtime/vk_image.c +++ b/src/vulkan/runtime/vk_image.c @@ -535,6 +535,23 @@ vk_image_view_init(struct vk_device *device, image_view->extent = vk_image_mip_level_extent(image, image_view->base_mip_level); + if (vk_format_is_compressed(image->format) && + !vk_format_is_compressed(image_view->format)) { + const struct util_format_description *fmt = + vk_format_description(image_view->format); + + /* Non-compressed view of compressed image only works for single MIP + * views. + */ + assert(image_view->level_count == 1); + image_view->extent.width = + DIV_ROUND_UP(image_view->extent.width, fmt->block.width); + image_view->extent.height = + DIV_ROUND_UP(image_view->extent.height, fmt->block.height); + image_view->extent.depth = + DIV_ROUND_UP(image_view->extent.depth, fmt->block.depth); + } + /* By default storage uses the same as the image properties, but it can be * overriden with VkImageViewSlicedCreateInfoEXT. */