diff --git a/src/imagination/vulkan/pvr_image.c b/src/imagination/vulkan/pvr_image.c index 8616305b033..3294a6ed633 100644 --- a/src/imagination/vulkan/pvr_image.c +++ b/src/imagination/vulkan/pvr_image.c @@ -321,34 +321,37 @@ VkResult pvr_CreateImageView(VkDevice _device, goto err_vk_image_view_destroy; } - /* Attachment state is created as if the mipmaps are not supported, so the - * baselevel is set to zero and num_mip_levels is set to 1. Which gives an - * impression that this is the only level in the image. This also requires - * that width, height and depth be adjusted as well. Given iview->vk.extent - * is already adjusted for base mip map level we use it here. - */ - /* TODO: Investigate and document the reason for above approach. */ - info.extent = iview->vk.extent; + if (image->vk.usage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) { + /* Attachment state is created as if the mipmaps are not supported, so the + * baselevel is set to zero and num_mip_levels is set to 1. Which gives an + * impression that this is the only level in the image. This also requires + * that width, height and depth be adjusted as well. Given + * iview->vk.extent is already adjusted for base mip map level we use it + * here. + */ + /* TODO: Investigate and document the reason for above approach. */ + info.extent = iview->vk.extent; - info.mip_levels = 1; - info.mipmaps_present = false; - info.stride = u_minify(image->physical_extent.width, info.base_level); - info.base_level = 0; - info.tex_state_type = PVR_TEXTURE_STATE_ATTACHMENT; + info.mip_levels = 1; + info.mipmaps_present = false; + info.stride = u_minify(image->physical_extent.width, info.base_level); + info.base_level = 0; + info.tex_state_type = PVR_TEXTURE_STATE_ATTACHMENT; - if (iview->vk.image->image_type == VK_IMAGE_TYPE_3D && - iview->vk.view_type == VK_IMAGE_VIEW_TYPE_2D) { - info.type = VK_IMAGE_VIEW_TYPE_3D; - } else { - info.type = iview->vk.view_type; + if (iview->vk.image->image_type == VK_IMAGE_TYPE_3D && + iview->vk.view_type == VK_IMAGE_VIEW_TYPE_2D) { + info.type = VK_IMAGE_VIEW_TYPE_3D; + } else { + info.type = iview->vk.view_type; + } + + result = pvr_pack_tex_state(device, + &info, + iview->texture_state[info.tex_state_type]); + if (result != VK_SUCCESS) + goto err_vk_image_view_destroy; } - result = pvr_pack_tex_state(device, - &info, - iview->texture_state[info.tex_state_type]); - if (result != VK_SUCCESS) - goto err_vk_image_view_destroy; - *pView = pvr_image_view_to_handle(iview); return VK_SUCCESS;