From d3c1fd53e284db7e8a63e8fd1d9219c710a2890e Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Tue, 26 Jan 2016 18:40:54 -0800 Subject: [PATCH] anv/image: Use custom VkBufferImageCopy for iview initialization Use a custom VkBufferImageCopy with the user-provided struct as the base. A few fields are modified when the iview is uncompressed and the underlying image is compressed. --- src/vulkan/anv_image.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index 6c1c92d61c6..9294bab621d 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -488,6 +488,8 @@ anv_image_view_init(struct anv_image_view *iview, { ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange; + VkImageViewCreateInfo mCreateInfo; + memcpy(&mCreateInfo, pCreateInfo, sizeof(VkImageViewCreateInfo)); assert(range->layerCount > 0); assert(range->baseMipLevel < image->levels); @@ -545,6 +547,11 @@ anv_image_view_init(struct anv_image_view *iview, iview->level_0_extent.width = DIV_ROUND_UP(image->extent.width , isl_layout->bw); iview->level_0_extent.height = DIV_ROUND_UP(image->extent.height, isl_layout->bh); iview->level_0_extent.depth = DIV_ROUND_UP(image->extent.depth , isl_layout->bd); + iview->level_0_extent.width = anv_minify(iview->level_0_extent.width , range->baseMipLevel); + iview->level_0_extent.height = anv_minify(iview->level_0_extent.height, range->baseMipLevel); + iview->level_0_extent.depth = anv_minify(iview->level_0_extent.depth , range->baseMipLevel); + mCreateInfo.subresourceRange.baseMipLevel = 0; + mCreateInfo.subresourceRange.baseArrayLayer = 0; } else { iview->level_0_extent.width = image->extent.width ; iview->level_0_extent.height = image->extent.height; @@ -561,7 +568,7 @@ anv_image_view_init(struct anv_image_view *iview, iview->nonrt_surface_state = alloc_surface_state(device, cmd_buffer); anv_fill_image_surface_state(device, iview->nonrt_surface_state, - iview, pCreateInfo, + iview, &mCreateInfo, VK_IMAGE_USAGE_SAMPLED_BIT); } else { iview->nonrt_surface_state.alloc_size = 0; @@ -571,7 +578,7 @@ anv_image_view_init(struct anv_image_view *iview, iview->color_rt_surface_state = alloc_surface_state(device, cmd_buffer); anv_fill_image_surface_state(device, iview->color_rt_surface_state, - iview, pCreateInfo, + iview, &mCreateInfo, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); } else { iview->color_rt_surface_state.alloc_size = 0; @@ -582,7 +589,7 @@ anv_image_view_init(struct anv_image_view *iview, if (has_matching_storage_typed_format(device, iview->format)) anv_fill_image_surface_state(device, iview->storage_surface_state, - iview, pCreateInfo, + iview, &mCreateInfo, VK_IMAGE_USAGE_STORAGE_BIT); else anv_fill_buffer_surface_state(device, iview->storage_surface_state, -- 2.30.2