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 | |
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')
-rw-r--r-- | src/vulkan/anv_image.c | 24 | ||||
-rw-r--r-- | src/vulkan/anv_private.h | 1 | ||||
-rw-r--r-- | src/vulkan/gen7_state.c | 1 | ||||
-rw-r--r-- | src/vulkan/gen8_state.c | 1 |
4 files changed, 27 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); diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 3326625ebb3..06ab1dc65a6 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -1202,6 +1202,7 @@ struct anv_image { VkExtent3D extent; uint32_t levels; uint32_t array_size; + VkImageUsageFlags usage; /**< VkImageCreateInfo::usage */ VkDeviceSize size; uint32_t alignment; diff --git a/src/vulkan/gen7_state.c b/src/vulkan/gen7_state.c index d7a4b10c6e8..5829d03d3e3 100644 --- a/src/vulkan/gen7_state.c +++ b/src/vulkan/gen7_state.c @@ -369,6 +369,7 @@ gen7_color_attachment_view_init(struct anv_image_view *iview, struct anv_surface *surface = anv_image_get_surface_for_color_attachment(image); + assert(image->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); anv_assert(pCreateInfo->arraySize > 0); anv_assert(pCreateInfo->mipLevel < image->levels); anv_assert(pCreateInfo->baseArraySlice + pCreateInfo->arraySize <= image->array_size); diff --git a/src/vulkan/gen8_state.c b/src/vulkan/gen8_state.c index e836613db42..3c479e1c23e 100644 --- a/src/vulkan/gen8_state.c +++ b/src/vulkan/gen8_state.c @@ -295,6 +295,7 @@ gen8_color_attachment_view_init(struct anv_image_view *iview, uint32_t depth = 1; /* RENDER_SURFACE_STATE::Depth */ uint32_t rt_view_extent = 1; /* RENDER_SURFACE_STATE::RenderTargetViewExtent */ + assert(image->usage & VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT); anv_assert(pCreateInfo->arraySize > 0); anv_assert(pCreateInfo->mipLevel < image->levels); anv_assert(pCreateInfo->baseArraySlice + pCreateInfo->arraySize <= image->array_size); |