From 3e44b14af8481ce99d5ef1fb8b54f348ac3af77c Mon Sep 17 00:00:00 2001 From: Lucas Fryzek Date: Fri, 19 May 2023 11:40:51 -0400 Subject: [PATCH] broadcom: Fix slice memory allocation logic for compressed textures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Compressed textures require their width and height padding to be calculated based on the number of blocks in the image. This change ensures that the number of blocks in the texture is a POT for mip levels > 1. Reviewed-by: Iago Toral Quiroga Reviewed-by: Alejandro PiƱeiro Part-of: --- src/broadcom/vulkan/v3dv_image.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/broadcom/vulkan/v3dv_image.c b/src/broadcom/vulkan/v3dv_image.c index 697ade34fce..168f74c9934 100644 --- a/src/broadcom/vulkan/v3dv_image.c +++ b/src/broadcom/vulkan/v3dv_image.c @@ -135,6 +135,16 @@ v3d_setup_plane_slices(struct v3dv_image *image, uint8_t plane, level_width = DIV_ROUND_UP(level_width, block_width); level_height = DIV_ROUND_UP(level_height, block_height); + /* Converting to the block size may have made it so the level_width + * and level height are no longer a POT for mip levels > 1, therefore + * if this is a mip level greater than 1 we set level_width and + * level_height to the next power of two + */ + if (i > 1) { + level_width = util_next_power_of_two(level_width); + level_height = util_next_power_of_two(level_height); + } + if (!image->tiled) { slice->tiling = V3D_TILING_RASTER; if (image->vk.image_type == VK_IMAGE_TYPE_1D)