From: Faith Ekstrand Date: Thu, 3 Aug 2023 21:10:59 +0000 (-0500) Subject: nvk: Implement VkGetImageSubresourceLyout X-Git-Tag: upstream/23.3.3~4493 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2a914028f13094291382edf2cdc0e7b562f074ae;p=platform%2Fupstream%2Fmesa.git nvk: Implement VkGetImageSubresourceLyout Part-of: --- diff --git a/src/nouveau/nil/nil_image.c b/src/nouveau/nil/nil_image.c index 6956fa3..e350828 100644 --- a/src/nouveau/nil/nil_image.c +++ b/src/nouveau/nil/nil_image.c @@ -197,3 +197,33 @@ nil_image_init(struct nouveau_ws_device *dev, return true; } + +uint64_t +nil_image_level_size_B(const struct nil_image *image, uint32_t level) +{ + assert(level < image->num_levels); + + /* See the nil_image::levels[] computations */ + struct nil_extent4d lvl_ext_B = image_level_extent_B(image, level); + struct nil_extent4d lvl_tiling_ext_B = + nil_tiling_extent_B(image->levels[level].tiling); + lvl_ext_B = nil_extent4d_align(lvl_ext_B, lvl_tiling_ext_B); + + return (uint64_t)lvl_ext_B.w * + (uint64_t)lvl_ext_B.h * + (uint64_t)lvl_ext_B.d; +} + +uint64_t +nil_image_level_depth_stride_B(const struct nil_image *image, uint32_t level) +{ + assert(level < image->num_levels); + + /* See the nil_image::levels[] computations */ + struct nil_extent4d lvl_ext_B = image_level_extent_B(image, level); + struct nil_extent4d lvl_tiling_ext_B = + nil_tiling_extent_B(image->levels[level].tiling); + lvl_ext_B = nil_extent4d_align(lvl_ext_B, lvl_tiling_ext_B); + + return (uint64_t)lvl_ext_B.w * (uint64_t)lvl_ext_B.h; +} diff --git a/src/nouveau/nil/nil_image.h b/src/nouveau/nil/nil_image.h index 86ba16d..766ee94 100644 --- a/src/nouveau/nil/nil_image.h +++ b/src/nouveau/nil/nil_image.h @@ -150,6 +150,10 @@ nil_image_level_layer_offset_B(const struct nil_image *image, return image->levels[level].offset_B + (layer * image->array_stride_B); } +uint64_t nil_image_level_size_B(const struct nil_image *image, + uint32_t level); +uint64_t nil_image_level_depth_stride_B(const struct nil_image *image, + uint32_t level); void nil_image_fill_tic(struct nouveau_ws_device *dev, const struct nil_image *image, diff --git a/src/nouveau/vulkan/nvk_image.c b/src/nouveau/vulkan/nvk_image.c index 1deb88a..5423aa2 100644 --- a/src/nouveau/vulkan/nvk_image.c +++ b/src/nouveau/vulkan/nvk_image.c @@ -115,6 +115,26 @@ nvk_GetImageMemoryRequirements2(VkDevice _device, } } +VKAPI_ATTR void VKAPI_CALL +nvk_GetImageSubresourceLayout(VkDevice device, + VkImage _image, + const VkImageSubresource *pSubresource, + VkSubresourceLayout *pLayout) +{ + VK_FROM_HANDLE(nvk_image, image, _image); + + *pLayout = (VkSubresourceLayout) { + .offset = nil_image_level_layer_offset_B(&image->nil, + pSubresource->mipLevel, + pSubresource->arrayLayer), + .size = nil_image_level_size_B(&image->nil, pSubresource->mipLevel), + .rowPitch = image->nil.levels[pSubresource->mipLevel].row_stride_B, + .arrayPitch = image->nil.array_stride_B, + .depthPitch = nil_image_level_depth_stride_B(&image->nil, + pSubresource->mipLevel), + }; +} + VKAPI_ATTR VkResult VKAPI_CALL nvk_BindImageMemory2(VkDevice _device, uint32_t bindInfoCount,