diff options
author | Chad Versace <[email protected]> | 2015-10-06 18:17:09 -0700 |
---|---|---|
committer | Chad Versace <[email protected]> | 2015-10-06 21:22:18 -0700 |
commit | 44143a1f4658143b8acc4aaf515603f9507442f1 (patch) | |
tree | 0d64d5e6e480a2ddff38a916086d024a45468402 /src/vulkan/anv_image.c | |
parent | cf603714cb0e2e5c5dfe7309b8938c910933aafa (diff) |
vk: Add anv_image::usage
It's a copy of VkImageCreateInfo::usage. Will be used for the
VkAttachmentView/VkImageView merge.
Diffstat (limited to 'src/vulkan/anv_image.c')
-rw-r--r-- | src/vulkan/anv_image.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/vulkan/anv_image.c b/src/vulkan/anv_image.c index 29a442daa43..b95cadca9e7 100644 --- a/src/vulkan/anv_image.c +++ b/src/vulkan/anv_image.c @@ -304,8 +304,21 @@ anv_image_create(VkDevice _device, image->format = anv_format_for_vk_format(pCreateInfo->format); image->levels = pCreateInfo->mipLevels; image->array_size = pCreateInfo->arraySize; + image->usage = pCreateInfo->usage; image->surf_type = surf_type; + if (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSFER_SOURCE_BIT) { + /* Meta will transfer from the image by binding it as a texture. */ + image->usage |= VK_IMAGE_USAGE_SAMPLED_BIT; + } + + if (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSFER_DESTINATION_BIT) { + /* Meta will transfer to the image by binding it as a color attachment, + * even if the image format is not a color format. + */ + image->usage |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; + } + if (likely(anv_format_is_color(image->format))) { r = anv_image_make_surface(create_info, image->format, &image->size, &image->alignment, @@ -458,6 +471,11 @@ anv_image_view_init(struct anv_image_view *iview, const VkImageViewCreateInfo* pCreateInfo, struct anv_cmd_buffer *cmd_buffer) { + ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); + + assert(image->usage & (VK_IMAGE_USAGE_SAMPLED_BIT | + VK_IMAGE_USAGE_STORAGE_BIT)); + switch (device->info.gen) { case 7: gen7_image_view_init(iview, device, pCreateInfo, cmd_buffer); @@ -506,6 +524,8 @@ anv_depth_stencil_view_init(struct anv_image_view *iview, { ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); + assert(image->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_BIT); + iview->image = image; iview->format = anv_format_for_vk_format(pCreateInfo->format); @@ -565,6 +585,10 @@ anv_color_attachment_view_init(struct anv_image_view *iview, const VkAttachmentViewCreateInfo* pCreateInfo, struct anv_cmd_buffer *cmd_buffer) { + ANV_FROM_HANDLE(anv_image, image, pCreateInfo->image); + + assert(image->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); + switch (device->info.gen) { case 7: gen7_color_attachment_view_init(iview, device, pCreateInfo, cmd_buffer); |