From db5a5fcd1886529d194e5635160526e95ad8d045 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 13 Oct 2015 15:50:02 -0700 Subject: [PATCH] anv/image: Add a basic implementation of GetImageSubresourceLayout --- src/vulkan/anv_image.c | 46 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index e72c592905f..e3991e22234 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -379,13 +379,55 @@ anv_DestroyImage(VkDevice _device, VkImage _image) anv_device_free(device, anv_image_from_handle(_image)); } +static void +anv_surface_get_subresource_layout(struct anv_image *image, + struct anv_surface *surface, + const VkImageSubresource *subresource, + VkSubresourceLayout *layout) +{ + /* If we are on a non-zero mip level or array slice, we need to + * calculate a real offset. + */ + anv_assert(subresource->mipLevel == 0); + anv_assert(subresource->arrayLayer == 0); + + layout->offset = surface->offset; + layout->rowPitch = surface->stride; + layout->depthPitch = surface->qpitch; + + /* FINISHME: We really shouldn't be doing this calculation here */ + if (image->array_size > 1) + layout->size = surface->qpitch * image->array_size; + else + layout->size = surface->stride * image->extent.height; +} + VkResult anv_GetImageSubresourceLayout( VkDevice device, - VkImage image, + VkImage _image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout) { - stub_return(VK_UNSUPPORTED); + ANV_FROM_HANDLE(anv_image, image, _image); + + switch (pSubresource->aspect) { + case VK_IMAGE_ASPECT_COLOR: + anv_surface_get_subresource_layout(image, &image->color_surface, + pSubresource, pLayout); + break; + case VK_IMAGE_ASPECT_DEPTH: + anv_surface_get_subresource_layout(image, &image->depth_surface, + pSubresource, pLayout); + break; + case VK_IMAGE_ASPECT_STENCIL: + anv_surface_get_subresource_layout(image, &image->stencil_surface, + pSubresource, pLayout); + break; + default: + return vk_error(VK_UNSUPPORTED); + } + + return VK_SUCCESS; } VkResult -- 2.30.2