From e6fb805f9a190664064c5fbcb730966343c28252 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Tue, 1 Sep 2020 13:02:32 +0200 Subject: [PATCH] v3dv: fix size computed by vkGetImageSubresourceLayout for 3D images Fixes: dEQP-VK.image.subresource_layout.3d.* Part-of: --- src/broadcom/vulkan/v3dv_image.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/broadcom/vulkan/v3dv_image.c b/src/broadcom/vulkan/v3dv_image.c index cefd22ebe1f..9ce966e2a45 100644 --- a/src/broadcom/vulkan/v3dv_image.c +++ b/src/broadcom/vulkan/v3dv_image.c @@ -357,7 +357,24 @@ v3dv_GetImageSubresourceLayout(VkDevice device, layout->rowPitch = slice->stride; layout->depthPitch = image->cube_map_stride; layout->arrayPitch = image->cube_map_stride; - layout->size = slice->size; + + if (image->type != VK_IMAGE_TYPE_3D) { + layout->size = slice->size; + } else { + /* For 3D images, the size of the slice represents the size of a 2D slice + * in the 3D image, so we have to multiply by the depth extent of the + * miplevel. For levels other than the first, we just compute the size + * as the distance between consecutive levels (notice that mip levels are + * arranged in memory from last to first). + */ + if (subresource->mipLevel == 0) { + layout->size = slice->size * image->extent.depth; + } else { + const struct v3d_resource_slice *prev_slice = + &image->slices[subresource->mipLevel - 1]; + layout->size = prev_slice->offset - slice->offset; + } + } } VkResult